Class: TPPlus::Nodes::PosregNode
- Inherits:
-
Object
- Object
- TPPlus::Nodes::PosregNode
- 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
-
#comment ⇒ Object
Returns the value of attribute comment.
Instance Method Summary collapse
- #comment_string ⇒ Object
- #component(m) ⇒ Object
- #component_valid?(c) ⇒ Boolean
- #eval(context, options = {}) ⇒ Object
-
#initialize(id) ⇒ PosregNode
constructor
A new instance of PosregNode.
- #requires_mixed_logic?(context) ⇒ Boolean
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
#comment ⇒ Object
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_string ⇒ Object
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
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,={}) [:method] ||= "" raise "Invalid component" unless component_valid?([:method]) "PR[#{@id}#{component([:method])}#{comment_string}]" end |
#requires_mixed_logic?(context) ⇒ Boolean
36 37 38 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 36 def requires_mixed_logic?(context) false end |