Class: Chronic::Span
- Inherits:
-
Range
- Object
- Range
- Chronic::Span
- Defined in:
- lib/chronic/chronic.rb
Overview
A Span represents a range of time. Since this class extends Range, you can use #begin and #end to get the beginning and ending times of the span (they will be of class Time)
Instance Method Summary collapse
-
#+(seconds) ⇒ Object
Add a number of seconds to this span, returning the resulting Span.
-
#-(seconds) ⇒ Object
Subtract a number of seconds to this span, returning the resulting Span.
-
#to_s ⇒ Object
Prints this span in a nice fashion.
-
#width ⇒ Object
Returns the width of this span in seconds.
Instance Method Details
#+(seconds) ⇒ Object
Add a number of seconds to this span, returning the resulting Span
209 210 211 |
# File 'lib/chronic/chronic.rb', line 209 def +(seconds) Span.new(self.begin + seconds, self.end + seconds) end |
#-(seconds) ⇒ Object
Subtract a number of seconds to this span, returning the resulting Span
215 216 217 |
# File 'lib/chronic/chronic.rb', line 215 def -(seconds) self + -seconds end |
#to_s ⇒ Object
Prints this span in a nice fashion
220 221 222 |
# File 'lib/chronic/chronic.rb', line 220 def to_s '(' << self.begin.to_s << '..' << self.end.to_s << ')' end |
#width ⇒ Object
Returns the width of this span in seconds
203 204 205 |
# File 'lib/chronic/chronic.rb', line 203 def width (self.end - self.begin).to_i end |