Class: MiniRuby::AST::FloatLiteralNode

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

Overview

Represents a float literal eg. ‘123.5`

Instance Attribute Summary collapse

Attributes inherited from Node

#span

Instance Method Summary collapse

Constructor Details

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

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



856
857
858
859
# File 'lib/miniruby/ast.rb', line 856

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

Instance Attribute Details

#valueObject (readonly)

: String



853
854
855
# File 'lib/miniruby/ast.rb', line 853

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

: (Object other) -> bool



862
863
864
865
866
# File 'lib/miniruby/ast.rb', line 862

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

  @value == other.value
end

#inspect(indent = 0) ⇒ Object

: (?Integer indent) -> String



876
877
878
# File 'lib/miniruby/ast.rb', line 876

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

#to_s(indent = 0) ⇒ Object

: (?Integer indent) -> String



870
871
872
# File 'lib/miniruby/ast.rb', line 870

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