Class: MiniRuby::AST::IntegerLiteralNode
- Inherits:
-
ExpressionNode
- Object
- Node
- ExpressionNode
- MiniRuby::AST::IntegerLiteralNode
- Defined in:
- lib/miniruby/ast.rb
Overview
Represents an integer literal eg. ‘123`
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) ⇒ IntegerLiteralNode
constructor
A new instance of IntegerLiteralNode.
- #inspect(indent = 0) ⇒ Object
- #to_s(indent = 0) ⇒ Object
Constructor Details
#initialize(value:, span: Span::ZERO) ⇒ IntegerLiteralNode
243 244 245 246 |
# File 'lib/miniruby/ast.rb', line 243 def initialize(value:, span: Span::ZERO) @span = span @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
240 241 242 |
# File 'lib/miniruby/ast.rb', line 240 def value @value end |
Instance Method Details
#==(other) ⇒ Object
249 250 251 252 253 |
# File 'lib/miniruby/ast.rb', line 249 def ==(other) return false unless other.is_a?(IntegerLiteralNode) @value == other.value end |
#inspect(indent = 0) ⇒ Object
261 262 263 |
# File 'lib/miniruby/ast.rb', line 261 def inspect(indent = 0) "#{INDENT_UNIT * indent}#{value}" end |
#to_s(indent = 0) ⇒ Object
256 257 258 |
# File 'lib/miniruby/ast.rb', line 256 def to_s(indent = 0) "#{INDENT_UNIT * indent}#{value}" end |