Sha256: e12901e7c370296e5a28e61363f5d065397040bec47410a1203efd74af574301

Contents?: true

Size: 651 Bytes

Versions: 1

Compression:

Stored size: 651 Bytes

Contents

module FilterParam
  module AST
    module Literals
      class Boolean < Literal
        def initialize(value)
          @value = (value.to_s == "true")
        end

        def data_type
          :boolean
        end

        private_class_method :new

        TRUE = new("true")
        FALSE = new("false")

        private

        def to_boolean
          self
        end

        def to_string
          Literals::String.new(value)
        end

        def to_integer
          Literals::Integer.new(value ? 1 : 0)
        end

        def to_decimal
          Literals::Decimal.new(value ? 1.0 : 0.0)
        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/boolean.rb