Class: MiniRuby::AST::IdentifierNode
- Inherits:
-
ExpressionNode
- Object
- Node
- ExpressionNode
- MiniRuby::AST::IdentifierNode
- Defined in:
- lib/miniruby/ast.rb
Overview
Represents an identifier like ‘a`, `foo`
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
: String.
Attributes inherited from Node
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(value:, span: Span::ZERO) ⇒ IdentifierNode
constructor
: (value: String, ?span: Span) -> void.
-
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String.
-
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String.
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
#value ⇒ Object (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 |