class ClockTime::Span
Attributes
from[R]
to[R]
Public Class Methods
new(from, to)
click to toggle source
# File lib/clock_time/span.rb, line 12 def initialize(from, to) if !from.is_a?(ClockTime) || !to.is_a?(ClockTime) raise ArgumentError, 'invalid span' end @from = from @to = to end
parse(from_string, to_string)
click to toggle source
# File lib/clock_time/span.rb, line 5 def parse(from_string, to_string) from = ClockTime.parse(from_string) to = ClockTime.parse(to_string) new(from, to) end
Public Instance Methods
==(span)
click to toggle source
# File lib/clock_time/span.rb, line 31 def ==(span) from == span.from && to == span.to end
duration()
click to toggle source
# File lib/clock_time/span.rb, line 20 def duration return @to - @from + 24.hours if @to < @from @to - @from end
to_times(date)
click to toggle source
# File lib/clock_time/span.rb, line 25 def to_times(date) from_t = from.to_time(date) to_t = to.next_time(from_t) return [from_t, to_t] end