Class: TPPlus::Nodes::TimerMethodNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/tp_plus/nodes/timer_method_node.rb

Instance Method Summary collapse

Methods inherited from BaseNode

#can_be_inlined?

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,options={})
  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

Returns:

  • (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