Class: TurbaChronos::Day
- Inherits:
-
Object
- Object
- TurbaChronos::Day
- Defined in:
- lib/turba_chronos/day.rb
Defined Under Namespace
Classes: TempTimerange
Instance Attribute Summary collapse
-
#beginning_of_day ⇒ Object
readonly
Returns the value of attribute beginning_of_day.
Instance Method Summary collapse
- #current_timeframe ⇒ Object
- #current_timeframe_index ⇒ Object
- #date ⇒ Object
-
#initialize(beginning_of_day, periods, timeranges_for_days) ⇒ Day
constructor
A new instance of Day.
- #opened? ⇒ Boolean
- #timeframes ⇒ Object
Constructor Details
#initialize(beginning_of_day, periods, timeranges_for_days) ⇒ Day
Returns a new instance of Day.
4 5 6 7 8 |
# File 'lib/turba_chronos/day.rb', line 4 def initialize(beginning_of_day, periods, timeranges_for_days) @beginning_of_day = beginning_of_day.to_time @rules = get_rules_for_day(periods) @timeranges_for_days = timeranges_for_days end |
Instance Attribute Details
#beginning_of_day ⇒ Object (readonly)
Returns the value of attribute beginning_of_day.
3 4 5 |
# File 'lib/turba_chronos/day.rb', line 3 def beginning_of_day @beginning_of_day end |
Instance Method Details
#current_timeframe ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/turba_chronos/day.rb', line 22 def current_timeframe get_timeframes(:timeranges).each do |timeframe| return timeframe if timeframe.timerange === TurbaChronos.current_numeric_time end range = (Time.now.utc.beginning_of_hour.strftime("%k%M").to_i..Time.now.utc.end_of_hour.strftime("%k%M").to_i) return TempTimerange.new(range, 6) end |
#current_timeframe_index ⇒ Object
31 32 33 |
# File 'lib/turba_chronos/day.rb', line 31 def current_timeframe_index timeframes.map {|x| x.timerange}.index(current_timeframe.timerange) end |
#date ⇒ Object
10 11 12 |
# File 'lib/turba_chronos/day.rb', line 10 def date @date ||= @beginning_of_day.to_datetime.iso8601 end |
#opened? ⇒ Boolean
14 15 16 |
# File 'lib/turba_chronos/day.rb', line 14 def opened? current_timeframe.level != 6 end |
#timeframes ⇒ Object
18 19 20 |
# File 'lib/turba_chronos/day.rb', line 18 def timeframes @timeframes ||= get_timeframes(:business_timeranges) end |