Class: TPPlus::Nodes::TimerMethodNode
- Defined in:
- lib/tp_plus/nodes/timer_method_node.rb
Instance Method Summary collapse
- #eval(context, options = {}) ⇒ Object
-
#initialize(method, target) ⇒ TimerMethodNode
constructor
A new instance of TimerMethodNode.
- #requires_mixed_logic?(context) ⇒ Boolean
- #timer(context) ⇒ Object
Methods inherited from BaseNode
Constructor Details
#initialize(method, target) ⇒ TimerMethodNode
Returns a new instance of TimerMethodNode.
4 5 6 7 |
# File 'lib/tp_plus/nodes/timer_method_node.rb', line 4 def initialize(method, target) @method = method @target = target end |
Instance Method Details
#eval(context, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tp_plus/nodes/timer_method_node.rb', line 17 def eval(context,={}) case @method when "start" "#{timer(context)}=START" when "stop" "#{timer(context)}=STOP" when "reset" "#{timer(context)}=RESET" when "restart" "#{timer(context)}=STOP ;\n#{timer(context)}=RESET ;\n#{timer(context)}=START" else raise "Invalid timer method (#{@method})" end end |
#requires_mixed_logic?(context) ⇒ Boolean
9 10 11 |
# File 'lib/tp_plus/nodes/timer_method_node.rb', line 9 def requires_mixed_logic?(context) true end |
#timer(context) ⇒ Object
13 14 15 |
# File 'lib/tp_plus/nodes/timer_method_node.rb', line 13 def timer(context) @timer ||= @target.eval(context) end |