Class: Timeframes::Series

Inherits:
Object
  • Object
show all
Defined in:
lib/timeframes/series.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#timeframesObject (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_wordsObject



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

#startObject



20
21
22
# File 'lib/timeframes/series.rb', line 20

def start
  @timeframes.first.start
end

#stopObject



24
25
26
# File 'lib/timeframes/series.rb', line 24

def stop
  @timeframes.last.stop
end

#total_durationObject



28
29
30
# File 'lib/timeframes/series.rb', line 28

def total_duration
  @timeframes.map(&:duration).sum
end