Class: SpotFeel::NumericLiteral

Inherits:
Node
  • Object
show all
Defined in:
lib/spot_feel/nodes.rb

Overview

  1. numeric literal = [ “-” ] , ( digits , [ “.”, digits ] | “.” , digits ) ;

Instance Method Summary collapse

Methods inherited from Node

#qualified_names_in_context, #raise_evaluation_error

Instance Method Details

#eval(_context = {}) ⇒ Object



357
358
359
360
361
362
363
# File 'lib/spot_feel/nodes.rb', line 357

def eval(_context = {})
  if text_value.include?(".")
    text_value.to_f
  else
    text_value.to_i
  end
end