Class: ClockTime::Span
- Inherits:
-
Object
- Object
- ClockTime::Span
- Defined in:
- lib/clock_time/span.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
- #==(span) ⇒ Object
- #duration ⇒ Object
-
#initialize(from, to) ⇒ Span
constructor
A new instance of Span.
- #to_times(date) ⇒ Object
Constructor Details
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
2 3 4 |
# File 'lib/clock_time/span.rb', line 2 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
2 3 4 |
# File 'lib/clock_time/span.rb', line 2 def to @to end |
Class Method Details
Instance Method Details
#==(span) ⇒ Object
31 32 33 |
# File 'lib/clock_time/span.rb', line 31 def ==(span) from == span.from && to == span.to end |
#duration ⇒ Object
20 21 22 23 |
# File 'lib/clock_time/span.rb', line 20 def duration return @to - @from + 24.hours if @to < @from @to - @from end |
#to_times(date) ⇒ Object
25 26 27 28 29 |
# 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 |