Sha256: 97690bf439ab079b8fa2ad9ef9c388cd14c4ba6a4f597514b67029943fe64bb4

Contents?: true

Size: 511 Bytes

Versions: 1

Compression:

Stored size: 511 Bytes

Contents

require "bigdecimal"

module FilterParam
  module AST
    module Literals
      class Decimal < Integer
        def initialize(value)
          @value = BigDecimal(value.to_s)
        rescue ArgumentError
          raise InvalidLiteral.new("Invalid Decimal: #{value}")
        end

        def data_type
          :decimal
        end

        private

        def to_integer
          Literals::Integer.new(value.to_i)
        end

        def to_decimal
          self
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
filter_param-0.1.2 lib/filter_param/ast/literals/decimal.rb