Class: Foxtail::Syntax::Parser::AST::NumberLiteral
- Inherits:
-
BaseLiteral
- Object
- BaseNode
- SyntaxNode
- BaseLiteral
- Foxtail::Syntax::Parser::AST::NumberLiteral
- Defined in:
- lib/foxtail/syntax/parser/ast/number_literal.rb
Overview
Represents numeric literals (integers and floats)
Instance Attribute Summary
Attributes inherited from BaseLiteral
Attributes inherited from SyntaxNode
Attributes inherited from BaseNode
Instance Method Summary collapse
-
#parse ⇒ Hash
Parse the number literal value and return as a Hash.
Methods inherited from BaseLiteral
Methods inherited from SyntaxNode
Methods inherited from BaseNode
#==, #accept, #children, #initialize, #to_h
Constructor Details
This class inherits a constructor from Foxtail::Syntax::Parser::AST::BaseLiteral
Instance Method Details
#parse ⇒ Hash
Parse the number literal value and return as a Hash
11 12 13 14 15 16 17 18 19 |
# File 'lib/foxtail/syntax/parser/ast/number_literal.rb', line 11 def parse value_str = @value if value_str.include?(".") {value: Float(value_str)} else {value: Integer(value_str, 10)} end end |