Class: Timeframes::Series
- Inherits:
-
Object
- Object
- Timeframes::Series
- Defined in:
- lib/timeframes/series.rb
Instance Attribute Summary collapse
-
#timeframes ⇒ Object
readonly
Returns the value of attribute timeframes.
Instance Method Summary collapse
- #<<(other) ⇒ Object
-
#initialize(timeframes = []) ⇒ Series
constructor
A new instance of Series.
- #series_in_words ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #total_duration ⇒ Object
Constructor Details
#initialize(timeframes = []) ⇒ Series
Returns a new instance of Series.
5 6 7 8 |
# File 'lib/timeframes/series.rb', line 5 def initialize(timeframes = []) @timeframes = timeframes @timeframes.sort! end |
Instance Attribute Details
#timeframes ⇒ Object (readonly)
Returns the value of attribute timeframes.
3 4 5 |
# File 'lib/timeframes/series.rb', line 3 def timeframes @timeframes end |
Instance Method Details
#<<(other) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/timeframes/series.rb', line 10 def <<(other) if other.class == Timeframes::Series @timeframes << other.timeframes elsif other.class == Timeframes::Frame @timeframes << other else raise ArgumentError end end |
#series_in_words ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/timeframes/series.rb', line 32 def series_in_words if check_sequential sequential_output elsif pattern = check_common_weekday common_weekday_output(pattern) elsif check_common_monthday # stub else default_output end end |
#start ⇒ Object
20 21 22 |
# File 'lib/timeframes/series.rb', line 20 def start @timeframes.first.start end |
#stop ⇒ Object
24 25 26 |
# File 'lib/timeframes/series.rb', line 24 def stop @timeframes.last.stop end |
#total_duration ⇒ Object
28 29 30 |
# File 'lib/timeframes/series.rb', line 28 def total_duration @timeframes.map(&:duration).sum end |