Class: RubyJsonParser::AST::NumberLiteralNode

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

Overview

Represents a number literal eg. ‘123.5`

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ NumberLiteralNode

Returns a new instance of NumberLiteralNode.



116
117
118
# File 'lib/ruby_json_parser/ast.rb', line 116

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



113
114
115
# File 'lib/ruby_json_parser/ast.rb', line 113

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



121
122
123
124
125
# File 'lib/ruby_json_parser/ast.rb', line 121

def ==(other)
  return false unless other.is_a?(NumberLiteralNode)

  value == other.value
end

#inspect(indent = 0) ⇒ Object



133
134
135
# File 'lib/ruby_json_parser/ast.rb', line 133

def inspect(indent = 0)
  "#{INDENT_UNIT * indent}#{value}"
end

#to_sObject



128
129
130
# File 'lib/ruby_json_parser/ast.rb', line 128

def to_s
  value
end