Class: DrgDSL::Ast::DrgLink

Inherits:
Object
  • Object
show all
Includes:
Node
Defined in:
lib/drgdsl/ast.rb

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

Instance Method Summary collapse

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.

Parameters:

  • name (String)

    either a drg or adrg name



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

#nameObject (readonly)

Returns the value of attribute name.



191
192
193
# File 'lib/drgdsl/ast.rb', line 191

def name
  @name
end

#variableObject (readonly)

Returns the value of attribute variable.



191
192
193
# File 'lib/drgdsl/ast.rb', line 191

def variable
  @variable
end

Instance Method Details

#hashObject



203
204
205
# File 'lib/drgdsl/ast.rb', line 203

def hash
  @hash ||= [type, name, variable].hash
end

#to_hashObject



199
200
201
# File 'lib/drgdsl/ast.rb', line 199

def to_hash
  { drg_link: { var: variable.to_hash, name: name } }
end