Class: Gloo::Expr::LDecimal

Inherits:
Core::Literal show all
Defined in:
lib/gloo/expr/l_decimal.rb

Instance Attribute Summary

Attributes inherited from Core::Literal

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Literal

#initialize

Constructor Details

This class inherits a constructor from Gloo::Core::Literal

Class Method Details

.decimal?(token) ⇒ Boolean

Is the given token a decimal?

Returns:

  • (Boolean)


14
15
16
17
18
19
# File 'lib/gloo/expr/l_decimal.rb', line 14

def self.decimal?( token )
  return true if token.is_a? Numeric

  s = token.strip
  return s.to_f.to_s == s
end

Instance Method Details

#set_value(value) ⇒ Object

Set the value, converting to an integer.



24
25
26
27
28
# File 'lib/gloo/expr/l_decimal.rb', line 24

def set_value( value )
  value = value.to_s if value.is_a? Numeric

  @value = value.to_f
end

#to_sObject

Get string representation



33
34
35
# File 'lib/gloo/expr/l_decimal.rb', line 33

def to_s
  return self.value.to_s
end