Sha256: b3840a41d558d1c35e5da2990716af108e224c81151a4e76483315148f152661

Contents?: true

Size: 662 Bytes

Versions: 7

Compression:

Stored size: 662 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

      def to_s
        return self.value.to_s
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gloo-0.6.1 lib/gloo/expr/l_decimal.rb
gloo-0.6.0 lib/gloo/expr/l_decimal.rb
gloo-0.5.4 lib/gloo/expr/l_decimal.rb
gloo-0.5.3 lib/gloo/expr/l_decimal.rb
gloo-0.5.2 lib/gloo/expr/l_decimal.rb
gloo-0.5.1 lib/gloo/expr/l_decimal.rb
gloo-0.5.0 lib/gloo/expr/l_decimal.rb