Class: TPPlus::Nodes::IndirectNode

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

Instance Method Summary collapse

Constructor Details

#initialize(type, target) ⇒ IndirectNode

Returns a new instance of IndirectNode.



4
5
6
7
# File 'lib/tp_plus/nodes/indirect_node.rb', line 4

def initialize(type, target)
  @type = type
  @target = target
end

Instance Method Details

#eval(context, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/tp_plus/nodes/indirect_node.rb', line 39

def eval(context,options={})
  s = "#{string}[#{@target.eval(context)}]"
  if options[:opposite]
    s = "!#{s}"
  end
  if options[:as_condition]
    s = "(#{s})"
  end
  s
end

#requires_mixed_logic?(context) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/tp_plus/nodes/indirect_node.rb', line 30

def requires_mixed_logic?(context)
  case @type
  when :flag#, :timer
    true
  else
    false
  end
end

#stringObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tp_plus/nodes/indirect_node.rb', line 9

def string
  case @type
  when :position
    "P"
  when :position_register
    "PR"
  when :flag
    "F"
  when :timer
    "TIMER"
  when :register
    "R"
  when :user_alarm
    "UALM"
  when :user_frame
    "UFRAME"
  else
    raise "Invalid indirect type"
  end
end