Class: DrgDSL::Ast::Constant
Overview
“3”, “‘MDC’”, …
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(value) ⇒ Constant
constructor
A new instance of Constant.
- #to_hash ⇒ Object
- #to_s ⇒ Object
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
#value ⇒ Object (readonly)
Returns the value of attribute value.
444 445 446 |
# File 'lib/drgdsl/ast.rb', line 444 def value @value end |
Instance Method Details
#hash ⇒ Object
458 459 460 |
# File 'lib/drgdsl/ast.rb', line 458 def hash @hash ||= [type, value].hash end |
#to_hash ⇒ Object
454 455 456 |
# File 'lib/drgdsl/ast.rb', line 454 def to_hash { constant: { value: value } } end |
#to_s ⇒ Object
450 451 452 |
# File 'lib/drgdsl/ast.rb', line 450 def to_s value.to_s end |