class Dhall::Double

Public Class Methods

as_dhall() click to toggle source
# File lib/dhall/ast.rb, line 1213
def self.as_dhall
        Builtins[:Double]
end

Public Instance Methods

===(other) click to toggle source
# File lib/dhall/ast.rb, line 1225
def ===(other)
        self == other || value === other
end
as_json() click to toggle source
# File lib/dhall/ast.rb, line 1242
def as_json
        self
end
coerce(other) click to toggle source
# File lib/dhall/ast.rb, line 1229
def coerce(other)
        return [other, self] if other.is_a?(Double)
        [Double.new(value: other.to_f), self]
end
eql?(other) click to toggle source
# File lib/dhall/ast.rb, line 1234
def eql?(other)
        other.is_a?(Double) && to_cbor == other.to_cbor
end
single?() click to toggle source
# File lib/dhall/ast.rb, line 1238
def single?
        [value].pack("g").unpack("g").first == value
end
to_cbor(packer=nil) click to toggle source
# File lib/dhall/ast.rb, line 1250
def to_cbor(packer=nil)
        if [0, Float::INFINITY, -Float::INFINITY].include?(value) || value.nan?
                return value.to_cbor(packer)
        end

        # Dhall spec requires *not* using half-precision CBOR floats
        bytes = single? ? [0xFA, value].pack("Cg") : [0xFB, value].pack("CG")
        if packer
                packer.buffer.write(bytes)
                packer
        else
                bytes
        end
end
to_f() click to toggle source
# File lib/dhall/ast.rb, line 1221
def to_f
        value
end
to_json() click to toggle source
# File lib/dhall/ast.rb, line 1246
def to_json
        value.to_json
end
to_s() click to toggle source
# File lib/dhall/ast.rb, line 1217
def to_s
        value.to_s
end