Class: MiniRuby::AST::IdentifierNode

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

Overview

Represents an identifier like ‘a`, `foo`

Instance Attribute Summary collapse

Attributes inherited from Node

#span

Instance Method Summary collapse

Constructor Details

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

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



309
310
311
312
# File 'lib/miniruby/ast.rb', line 309

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

Instance Attribute Details

#valueObject (readonly)

: String



306
307
308
# File 'lib/miniruby/ast.rb', line 306

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

: (Object other) -> bool



315
316
317
318
319
# File 'lib/miniruby/ast.rb', line 315

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

  @value == other.value
end

#inspect(indent = 0) ⇒ Object

: (?Integer indent) -> String



329
330
331
# File 'lib/miniruby/ast.rb', line 329

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

#to_s(indent = 0) ⇒ Object

: (?Integer indent) -> String



323
324
325
# File 'lib/miniruby/ast.rb', line 323

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