Class: DrgDSL::Ast::Constant

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

Overview

“3”, “‘MDC’”, …

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(value) ⇒ Constant

Returns a new instance of Constant.



446
447
448
# File 'lib/drgdsl/ast.rb', line 446

def initialize(value)
  @value = value.to_s.strip.tr("'", '')
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



444
445
446
# File 'lib/drgdsl/ast.rb', line 444

def value
  @value
end

Instance Method Details

#hashObject



458
459
460
# File 'lib/drgdsl/ast.rb', line 458

def hash
  @hash ||= [type, value].hash
end

#to_hashObject



454
455
456
# File 'lib/drgdsl/ast.rb', line 454

def to_hash
  { constant: { value: value } }
end

#to_sObject



450
451
452
# File 'lib/drgdsl/ast.rb', line 450

def to_s
  value.to_s
end