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
Returns the value of attribute value.
Attributes inherited from Node
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value:, span: Span::ZERO) ⇒ IdentifierNode
constructor
A new instance of IdentifierNode.
- #inspect(indent = 0) ⇒ Object
- #to_s(indent = 0) ⇒ Object
Constructor Details
#initialize(value:, span: Span::ZERO) ⇒ IdentifierNode
Returns a new instance of IdentifierNode.
301 302 303 304 |
# File 'lib/miniruby/ast.rb', line 301 def initialize(value:, span: Span::ZERO) @span = span @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
298 299 300 |
# File 'lib/miniruby/ast.rb', line 298 def value @value end |
Instance Method Details
#==(other) ⇒ Object
307 308 309 310 311 |
# File 'lib/miniruby/ast.rb', line 307 def ==(other) return false unless other.is_a?(IdentifierNode) @value == other.value end |
#inspect(indent = 0) ⇒ Object
319 320 321 |
# File 'lib/miniruby/ast.rb', line 319 def inspect(indent = 0) "#{INDENT_UNIT * indent}#{@value}" end |
#to_s(indent = 0) ⇒ Object
314 315 316 |
# File 'lib/miniruby/ast.rb', line 314 def to_s(indent = 0) "#{INDENT_UNIT * indent}#{@value}" end |