Class: RKelly::JS::Boolean

Inherits:
Base
  • Object
show all
Defined in:
lib/rkelly/js/boolean.rb

Instance Attribute Summary

Attributes inherited from Base

#properties, #return, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #can_put?, #default_value, #delete, #has_property?, #returned?

Constructor Details

#initialize(*args) ⇒ Boolean

Returns a new instance of Boolean.



10
11
12
13
14
15
16
17
18
# File 'lib/rkelly/js/boolean.rb', line 10

def initialize(*args)
  super()
  value = args.first.nil? ? false : args.first
  self['valueOf'] = value
  self['valueOf'].function = lambda {
    value
  }
  self['toString'] = args.first.to_s
end

Class Method Details

.create(*args) ⇒ Object



5
6
7
8
# File 'lib/rkelly/js/boolean.rb', line 5

def create(*args)
  return false if args.length == 0
  self.new(args.first)
end