Class: TPPlus::Nodes::PosregNode

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

Constant Summary collapse

COMPONENTS =
{
  "x" => 1,
  "y" => 2,
  "z" => 3,
  "w" => 4,
  "p" => 5,
  "r" => 6
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ PosregNode

Returns a new instance of PosregNode.



15
16
17
18
# File 'lib/tp_plus/nodes/posreg_node.rb', line 15

def initialize(id)
  @id = id
  @comment = ""
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



14
15
16
# File 'lib/tp_plus/nodes/posreg_node.rb', line 14

def comment
  @comment
end

Instance Method Details

#comment_stringObject



20
21
22
23
24
# File 'lib/tp_plus/nodes/posreg_node.rb', line 20

def comment_string
  return "" if @comment == ""

  ":#{@comment}"
end

#component(m) ⇒ Object



26
27
28
29
30
# File 'lib/tp_plus/nodes/posreg_node.rb', line 26

def component(m)
  return "" if m == ""

  ",#{COMPONENTS[m]}"
end

#component_valid?(c) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/tp_plus/nodes/posreg_node.rb', line 32

def component_valid?(c)
  [""].concat(COMPONENTS.keys).include? c
end

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



40
41
42
43
44
45
# File 'lib/tp_plus/nodes/posreg_node.rb', line 40

def eval(context,options={})
  options[:method] ||= ""
  raise "Invalid component" unless component_valid?(options[:method])

  "PR[#{@id}#{component(options[:method])}#{comment_string}]"
end

#requires_mixed_logic?(context) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/tp_plus/nodes/posreg_node.rb', line 36

def requires_mixed_logic?(context)
  false
end