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

: (value: String, ?span: Span) -> void



887
888
889
890
# File 'lib/miniruby/ast.rb', line 887

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

Instance Attribute Details

#valueObject (readonly)

: String



884
885
886
# File 'lib/miniruby/ast.rb', line 884

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

: (Object other) -> bool



893
894
895
896
897
# File 'lib/miniruby/ast.rb', line 893

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

  @value == other.value
end

#inspect(indent = 0) ⇒ Object

: (?Integer indent) -> String



907
908
909
# File 'lib/miniruby/ast.rb', line 907

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

#to_s(indent = 0) ⇒ Object

: (?Integer indent) -> String



901
902
903
# File 'lib/miniruby/ast.rb', line 901

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