Class: Bool
Instance Attribute Summary
Attributes inherited from DataType
Instance Method Summary collapse
- #as_string ⇒ Object
-
#initialize(val = nil) ⇒ Bool
constructor
A new instance of Bool.
Constructor Details
#initialize(val = nil) ⇒ Bool
Returns a new instance of Bool.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sdx/vm/datatypes.rb', line 47 def initialize(val=nil) if val @internal = true else @internal = false end @fields = { "__as_string" => (NativeFn.new 0, (Proc.new do as_string end)), "__as_code_string" => (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 |
Instance Method Details
#as_string ⇒ Object
69 70 71 |
# File 'lib/sdx/vm/datatypes.rb', line 69 def as_string Str.new ({ true => "true", false => "false" }[@internal]) end |