Class: TurbaChronos::Timeline
- Inherits:
-
Object
- Object
- TurbaChronos::Timeline
- Defined in:
- lib/turba_chronos/timeline.rb
Defined Under Namespace
Classes: TempTimeframe
Instance Method Summary collapse
- #business_timeranges ⇒ Object
- #current_day ⇒ Object
- #current_timeframe ⇒ Object
- #days ⇒ Object
-
#initialize(periods, from, to) ⇒ Timeline
constructor
A new instance of Timeline.
- #levels ⇒ Object
- #next ⇒ Object
- #opened? ⇒ Boolean
- #reopen ⇒ Object
- #timeranges_for_days ⇒ Object
Constructor Details
Instance Method Details
#business_timeranges ⇒ Object
9 10 11 12 13 |
# File 'lib/turba_chronos/timeline.rb', line 9 def business_timeranges timeranges_for_days[:business_timeranges].map! {|x| [x.min.to_s.rjust(4, '0').insert(2, ':'), x.max.to_s.rjust(4, '0').insert(2, ':')] } end |
#current_day ⇒ Object
27 28 29 |
# File 'lib/turba_chronos/timeline.rb', line 27 def current_day @current_day ||= days.first end |
#current_timeframe ⇒ Object
59 60 61 |
# File 'lib/turba_chronos/timeline.rb', line 59 def current_timeframe current_day.current_timeframe end |
#days ⇒ Object
23 24 25 |
# File 'lib/turba_chronos/timeline.rb', line 23 def days @days ||= get_days(@from, @to) end |
#levels ⇒ Object
15 16 17 |
# File 'lib/turba_chronos/timeline.rb', line 15 def levels @levels ||= days.map(&:timeframes).flatten.map(&:level).uniq end |
#next ⇒ Object
35 36 37 |
# File 'lib/turba_chronos/timeline.rb', line 35 def next get_list(days)[0..2] end |
#opened? ⇒ Boolean
31 32 33 |
# File 'lib/turba_chronos/timeline.rb', line 31 def opened? current_day.opened? end |
#reopen ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/turba_chronos/timeline.rb', line 39 def reopen get_list(days).each do |data| return data if data.timeframe.level != 6 end iteration = 14 count = 0 loop do if count == 0 next_days = get_days(@to+1.day, @to+iteration.days) else next_days = get_days((@to+(count * iteration).days), (@to+((count+1) * iteration).days)) end get_list(next_days).each do |data| return data if data.timeframe.level != 6 end count += 1 end end |
#timeranges_for_days ⇒ Object
19 20 21 |
# File 'lib/turba_chronos/timeline.rb', line 19 def timeranges_for_days @timeranges_for_days ||= get_timeranges_for_days(@from, @to) end |