Sha256: 5c407421065d85fc906708a68b3e8413d18939cb4c837ed8d8db304d015e586d

Contents?: true

Size: 736 Bytes

Versions: 29

Compression:

Stored size: 736 Bytes

Contents

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

module GlooLang
  module Expr
    class LDecimal < GlooLang::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-lang-1.4.3 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.4.2 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.4.1 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.4.0 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.3.2 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.3.1 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.3.0 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.8 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.7 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.6 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.5 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.4 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.3 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.2 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.1 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.2.0 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.1.0 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.0.2 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.0.1 lib/gloo_lang/expr/l_decimal.rb
gloo-lang-1.0.0 lib/gloo_lang/expr/l_decimal.rb