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, }
- GROUPS =
{ "gp1" => "GP1", "gp2" => "GP2", "gp3" => "GP3", "gp4" => "GP4", "gp5" => "GP5" }
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #comment_string ⇒ Object
- #component(m) ⇒ Object
- #component_groups?(c) ⇒ Boolean
- #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.
24 25 26 27 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 24 def initialize(id) @id = id @comment = "" end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
22 23 24 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 22 def comment @comment end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 23 def id @id end |
Instance Method Details
#comment_string ⇒ Object
29 30 31 32 33 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 29 def comment_string return "" if @comment == "" ":#{@comment}" end |
#component(m) ⇒ Object
35 36 37 38 39 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 35 def component(m) return "" if m == "" ",#{COMPONENTS[m]}" end |
#component_groups?(c) ⇒ Boolean
45 46 47 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 45 def component_groups?(c) [""].concat(GROUPS.keys).include? c end |
#component_valid?(c) ⇒ Boolean
41 42 43 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 41 def component_valid?(c) [""].concat(COMPONENTS.keys).include? c end |
#eval(context, options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 53 def eval(context,={}) [:method] ||= "" group_string = GROUPS["gp" + [:group].eval(context).to_s] + ":" if [:group] raise "Invalid component" unless component_valid?([:method]) || component_groups?([:group]) "PR[#{group_string}#{@id}#{component([:method])}#{comment_string}]" end |
#requires_mixed_logic?(context) ⇒ Boolean
49 50 51 |
# File 'lib/tp_plus/nodes/posreg_node.rb', line 49 def requires_mixed_logic?(context) false end |