Class: TaskLoop::DateListRule
- Defined in:
- lib/taskloop/rules/date_list_rule.rb
Constant Summary
Constants inherited from Rule
Instance Attribute Summary collapse
Attributes inherited from Rule
Instance Method Summary collapse
- #dates_values ⇒ Object
- #desc ⇒ Object
-
#initialize(unit, dates) ⇒ DateListRule
constructor
A new instance of DateListRule.
- #is_conform_rule?(last_exec_time) ⇒ Boolean
Constructor Details
#initialize(unit, dates) ⇒ DateListRule
Returns a new instance of DateListRule.
21 22 23 24 25 26 27 |
# File 'lib/taskloop/rules/date_list_rule.rb', line 21 def initialize(unit, dates) super unit unless dates != nil && dates.length > 0 raise ArgumentError, "dates arguments need at least one value." end @dates = dates end |
Instance Attribute Details
#dates ⇒ Object
7 8 9 |
# File 'lib/taskloop/rules/date_list_rule.rb', line 7 def dates @dates ||= [] end |
Instance Method Details
#dates_values ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/taskloop/rules/date_list_rule.rb', line 11 def dates_values values = [] dates.each do |date| date_format = "%Y-%m-%d" date_object = Time.strptime(date, date_format) values.push(date_object) end return values end |
#desc ⇒ Object
39 40 41 |
# File 'lib/taskloop/rules/date_list_rule.rb', line 39 def desc super + "; date_list: #{dates.join(', ')}" end |
#is_conform_rule?(last_exec_time) ⇒ Boolean
29 30 31 32 33 34 35 36 37 |
# File 'lib/taskloop/rules/date_list_rule.rb', line 29 def is_conform_rule?(last_exec_time) current = Time.now result = false dates_values.each do |date| result = result || (date.year == current.year && date.month == current.month && date.day == current.day) end return result end |