Class: RKelly::JS::Object
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
constructor
A new instance of Object.
Methods inherited from Base
#[], #[]=, #can_put?, #default_value, #delete, #has_property?, #returned?
Constructor Details
#initialize(*args) ⇒ Object
Returns a new instance of Object.
22 23 24 25 26 27 |
# File 'lib/rkelly/js/object.rb', line 22 def initialize(*args) super() self['prototype'] = JS::ObjectPrototype.new self['valueOf'] = lambda { args.first || self } self['valueOf'].function = lambda { args.first || self } end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/rkelly/js/object.rb', line 4 def value @value end |
Class Method Details
.create(*args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rkelly/js/object.rb', line 6 def create(*args) arg = args.first return self.new if arg.nil? || arg == :undefined case arg when true, false JS::Boolean.new(arg) when Numeric JS::Number.new(arg) when ::String JS::String.new(arg) else self.new(arg) end end |