class Bool

Public Class Methods

new(val=nil) click to toggle source
# File lib/sdx/vm/datatypes.rb, line 48
def initialize(val=nil)
    if val
        @internal = true
    else
        @internal = false
    end
    @fields = {
        "__as_str" => (NativeFn.new 0, (Proc.new do
            as_string
        end)),
        "__as_code_str" => (NativeFn.new 0, (Proc.new do
            as_string
        end)),
        "__eq" => (NativeFnInternal.new (lambda do |other|
            Bool.new @internal == other[0].internal
        end)),
        "__neq" => (NativeFnInternal.new (lambda do |other|
            Bool.new @internal != other[0].internal
        end))
    }
end

Public Instance Methods

as_string() click to toggle source
# File lib/sdx/vm/datatypes.rb, line 70
def as_string
    Str.new ({ true => "true", false => "false" }[@internal])
end