Class: MiniRuby::AST::IntegerLiteralNode

Inherits:
ExpressionNode show all
Defined in:
lib/miniruby/ast.rb

Overview

Represents an integer literal eg. ‘123`

Instance Attribute Summary collapse

Attributes inherited from Node

#span

Instance Method Summary collapse

Constructor Details

#initialize(value:, span: Span::ZERO) ⇒ IntegerLiteralNode



243
244
245
246
# File 'lib/miniruby/ast.rb', line 243

def initialize(value:, span: Span::ZERO)
  @span = span
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



240
241
242
# File 'lib/miniruby/ast.rb', line 240

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



249
250
251
252
253
# File 'lib/miniruby/ast.rb', line 249

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

  @value == other.value
end

#inspect(indent = 0) ⇒ Object



261
262
263
# File 'lib/miniruby/ast.rb', line 261

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

#to_s(indent = 0) ⇒ Object



256
257
258
# File 'lib/miniruby/ast.rb', line 256

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