Class: Twostroke::Runtime::Types::BooleanObject

Inherits:
Object
  • Object
show all
Defined in:
lib/twostroke/runtime/types/boolean_object.rb

Instance Attribute Summary collapse

Attributes inherited from Object

#_class, #accessors, #data, #extensible, #properties, #prototype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#can_put, #construct, #constructing?, #default_value, #define_own_property, #delete, #delete!, #each_enumerable_property, #generic_items, #get, #get_own_property, #get_property, #has_accessor, #has_own_property, #has_property, #proto_put, #put, set_global_prototype, #typeof

Methods inherited from Value

#has_instance

Constructor Details

#initialize(boolean) ⇒ BooleanObject

Returns a new instance of BooleanObject.



15
16
17
18
19
# File 'lib/twostroke/runtime/types/boolean_object.rb', line 15

def initialize(boolean)
  @prototype = BooleanObject.constructor_function.get("prototype")
  super()
  @boolean = boolean
end

Instance Attribute Details

#booleanObject (readonly)

Returns the value of attribute boolean.



14
15
16
# File 'lib/twostroke/runtime/types/boolean_object.rb', line 14

def boolean
  @boolean
end

Class Method Details

.constructor_functionObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/twostroke/runtime/types/boolean_object.rb', line 3

def self.constructor_function
  @@constructor_function ||=
    Function.new(->(scope, this, args) { 
      if this.constructing?
        Twostroke::Runtime::Types.to_object(Twostroke::Runtime::Types.to_boolean(args[0] || Undefined.new))
      else
        Twostroke::Runtime::Types.to_boolean(args[0])
      end
    }, nil, "Boolean", [])
end

Instance Method Details

#to_rubyObject



21
22
23
# File 'lib/twostroke/runtime/types/boolean_object.rb', line 21

def to_ruby
  boolean
end