Sha256: 292d6f08472b82115a48b4321e039a4f5f647c551b4dc5a88a999d73d682b95f

Contents?: true

Size: 728 Bytes

Versions: 30

Compression:

Stored size: 728 Bytes

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# A literal decimal value.
#

module Gloo
  module Expr
    class LDecimal < Gloo::Core::Literal

      #
      # Is the given token a decimal?
      #
      def self.decimal?( token )
        return true if token.is_a? Numeric

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

      #
      # Set the value, converting to an integer.
      #
      def set_value( value )
        value = value.to_s if value.is_a? Numeric

        @value = value.to_f
      end

      #
      # Get string representation
      #
      def to_s
        return self.value.to_s
      end

    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gloo-2.0.0 lib/gloo/expr/l_decimal.rb
gloo-0.8.0 lib/gloo/expr/l_decimal.rb
gloo-0.7.7 lib/gloo/expr/l_decimal.rb
gloo-0.7.6 lib/gloo/expr/l_decimal.rb
gloo-0.7.5 lib/gloo/expr/l_decimal.rb
gloo-0.7.4 lib/gloo/expr/l_decimal.rb
gloo-0.7.3 lib/gloo/expr/l_decimal.rb
gloo-0.7.2 lib/gloo/expr/l_decimal.rb
gloo-0.7.1 lib/gloo/expr/l_decimal.rb
gloo-0.7.0 lib/gloo/expr/l_decimal.rb