Class: TurbaChronos::Rule
- Inherits:
-
Object
- Object
- TurbaChronos::Rule
- Defined in:
- lib/turba_chronos/rule.rb
Defined Under Namespace
Classes: TextTime
Instance Attribute Summary collapse
-
#business_hours ⇒ Object
Returns the value of attribute business_hours.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#range ⇒ Object
Returns the value of attribute range.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(rule, business_hours = false) ⇒ Rule
constructor
A new instance of Rule.
- #max ⇒ Object
- #min ⇒ Object
- #wdays ⇒ Object
Constructor Details
#initialize(rule, business_hours = false) ⇒ Rule
Returns a new instance of Rule.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/turba_chronos/rule.rb', line 8 def initialize(rule, business_hours=false) @business_hours = business_hours if rule.is_a?(Array) @wdays = rule[2..-2] self.start_time = rule[0] self.end_time = rule[1] else @wdays = [rule[:mo], rule[:tu], rule[:we], rule[:th], rule[:fr], rule[:sa], rule[:su]] self.start_time = rule[:s] self.end_time = rule[:e] end end |
Instance Attribute Details
#business_hours ⇒ Object
Returns the value of attribute business_hours.
6 7 8 |
# File 'lib/turba_chronos/rule.rb', line 6 def business_hours @business_hours end |
#end_time ⇒ Object
Returns the value of attribute end_time.
4 5 6 |
# File 'lib/turba_chronos/rule.rb', line 4 def end_time @end_time end |
#range ⇒ Object
Returns the value of attribute range.
5 6 7 |
# File 'lib/turba_chronos/rule.rb', line 5 def range @range end |
#start_time ⇒ Object
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/turba_chronos/rule.rb', line 3 def start_time @start_time end |
Instance Method Details
#max ⇒ Object
25 26 27 |
# File 'lib/turba_chronos/rule.rb', line 25 def max range.max end |
#min ⇒ Object
21 22 23 |
# File 'lib/turba_chronos/rule.rb', line 21 def min range.min end |
#wdays ⇒ Object
41 42 43 |
# File 'lib/turba_chronos/rule.rb', line 41 def wdays @cachewdays ||= @wdays.map(&:to_i) end |