Class: DrgDSL::Ast::DrgLink
Overview
A drg link originates from the grammar rule basic_or_drg_link This rule is of the form “variable (basic_expression | drg_link)” therefore a DrgLink has a variable and a name
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#variable ⇒ Object
readonly
Returns the value of attribute variable.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(name:, variable:) ⇒ DrgLink
constructor
A new instance of DrgLink.
- #to_hash ⇒ Object
Methods included from Node
#==, #accept, included, #mdc_equality?, node_classes, #pretty_print, #sep_equality?, type, #type
Constructor Details
#initialize(name:, variable:) ⇒ DrgLink
Returns a new instance of DrgLink.
194 195 196 197 |
# File 'lib/drgdsl/ast.rb', line 194 def initialize(name:, variable:) @name = name.to_s.strip.upcase @variable = variable end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
191 192 193 |
# File 'lib/drgdsl/ast.rb', line 191 def name @name end |
#variable ⇒ Object (readonly)
Returns the value of attribute variable.
191 192 193 |
# File 'lib/drgdsl/ast.rb', line 191 def variable @variable end |
Instance Method Details
#hash ⇒ Object
203 204 205 |
# File 'lib/drgdsl/ast.rb', line 203 def hash @hash ||= [type, name, variable].hash end |
#to_hash ⇒ Object
199 200 201 |
# File 'lib/drgdsl/ast.rb', line 199 def to_hash { drg_link: { var: variable.to_hash, name: name } } end |