Sha256: 292d6f08472b82115a48b4321e039a4f5f647c551b4dc5a88a999d73d682b95f

Contents?: true

Size: 728 Bytes

Versions: 29

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

29 entries across 29 versions & 1 rubygems

Version Path
gloo-3.5.0 lib/gloo/expr/l_decimal.rb
gloo-3.4.1 lib/gloo/expr/l_decimal.rb
gloo-3.4.0 lib/gloo/expr/l_decimal.rb
gloo-3.3.0 lib/gloo/expr/l_decimal.rb
gloo-3.2.0 lib/gloo/expr/l_decimal.rb
gloo-3.1.1 lib/gloo/expr/l_decimal.rb
gloo-3.1.0 lib/gloo/expr/l_decimal.rb
gloo-3.0.1 lib/gloo/expr/l_decimal.rb
gloo-3.0.0 lib/gloo/expr/l_decimal.rb
gloo-2.5.0 lib/gloo/expr/l_decimal.rb
gloo-2.4.3 lib/gloo/expr/l_decimal.rb
gloo-2.4.2 lib/gloo/expr/l_decimal.rb
gloo-2.4.1 lib/gloo/expr/l_decimal.rb
gloo-2.4.0 lib/gloo/expr/l_decimal.rb
gloo-2.3.1 lib/gloo/expr/l_decimal.rb
gloo-2.2.0 lib/gloo/expr/l_decimal.rb
gloo-2.1.0 lib/gloo/expr/l_decimal.rb
gloo-2.0.2 lib/gloo/expr/l_decimal.rb
gloo-2.0.1 lib/gloo/expr/l_decimal.rb
gloo-2.0.0 lib/gloo/expr/l_decimal.rb