Class: MiniRuby::AST::NextExpressionNode
- Inherits:
-
ExpressionNode
- Object
- Node
- ExpressionNode
- MiniRuby::AST::NextExpressionNode
- Defined in:
- lib/miniruby/ast.rb
Overview
Represents a next like ‘next`, `next 1 + 5 * a`
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
: ExpressionNode?.
Attributes inherited from Node
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(value: nil, span: Span::ZERO) ⇒ NextExpressionNode
constructor
: (?value: ExpressionNode?, ?span: Span) -> void.
-
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String.
-
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String.
Constructor Details
#initialize(value: nil, span: Span::ZERO) ⇒ NextExpressionNode
: (?value: ExpressionNode?, ?span: Span) -> void
506 507 508 509 |
# File 'lib/miniruby/ast.rb', line 506 def initialize(value: nil, span: Span::ZERO) @span = span @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
: ExpressionNode?
503 504 505 |
# File 'lib/miniruby/ast.rb', line 503 def value @value end |
Instance Method Details
#==(other) ⇒ Object
: (Object other) -> bool
512 513 514 515 516 |
# File 'lib/miniruby/ast.rb', line 512 def ==(other) return false unless other.is_a?(NextExpressionNode) @value == other.value end |
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String
530 531 532 533 534 535 536 537 |
# File 'lib/miniruby/ast.rb', line 530 def inspect(indent = 0) buff = String.new buff << "#{INDENT_UNIT * indent}(next" buff << " #{@value.inspect}" if @value buff << ')' buff end |
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String
520 521 522 523 524 525 526 |
# File 'lib/miniruby/ast.rb', line 520 def to_s(indent = 0) buff = String.new buff << "#{INDENT_UNIT * indent}next" buff << " #{@value}" if @value buff end |