Class: TaskLoop::AfterScopeRule
- Defined in:
- lib/taskloop/rules/after_scope_rule.rb
Constant Summary
Constants inherited from ScopeRule
Constants inherited from Rule
Instance Attribute Summary collapse
-
#left ⇒ Object
Returns the value of attribute left.
Attributes inherited from ScopeRule
Attributes inherited from Rule
Instance Method Summary collapse
- #desc ⇒ Object
-
#initialize(unit, left) ⇒ AfterScopeRule
constructor
A new instance of AfterScopeRule.
- #is_conform_rule?(last_exec_time) ⇒ Boolean
- #left_value ⇒ Object
Constructor Details
#initialize(unit, left) ⇒ AfterScopeRule
Returns a new instance of AfterScopeRule.
6 7 8 9 |
# File 'lib/taskloop/rules/after_scope_rule.rb', line 6 def initialize(unit, left) super unit, :after @left = left end |
Instance Attribute Details
#left ⇒ Object
Returns the value of attribute left.
4 5 6 |
# File 'lib/taskloop/rules/after_scope_rule.rb', line 4 def left @left end |
Instance Method Details
#desc ⇒ Object
80 81 82 |
# File 'lib/taskloop/rules/after_scope_rule.rb', line 80 def desc super + " #{left}" end |
#is_conform_rule?(last_exec_time) ⇒ Boolean
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/taskloop/rules/after_scope_rule.rb', line 59 def is_conform_rule?(last_exec_time) current = Time.now value = left_value result = false case @unit when :year then result = current.year >= value when :month then result = current.month >= value when :week then result = current.wday >= value when :day then result = current.day >= value when :hour then result = current.hour >= value when :minute then result = current.min >= value end return result end |
#left_value ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/taskloop/rules/after_scope_rule.rb', line 41 def left_value if (Task::DAY.has_key?(@left)) return Task::DAY[@left] end if (Task::WEEK.has_key?(@left)) return Task::WEEK[@left] end if (Task::MONTH.has_key?(@left)) return Task::MONTH[@left] end unless @left != nil && @left.is_a?(Integer) return -1 end return @left end |