Module: RubyRunJs::JsBooleanMethods

Extended by:
Helper
Defined in:
lib/ruby_run_js/object_methods/js_boolean.rb

Class Method Summary collapse

Methods included from Helper

check_object, get_member, get_member_dot, is_accessor_descriptor, is_callable, is_data_descriptor, is_generic_descriptor, is_primitive, make_error, strict_equality

Methods included from ConversionHelper

#convert_to_js_type, #to_boolean, #to_int32, #to_integer, #to_number, #to_object, #to_primitive, #to_string, #to_uint16, #to_uint32

Class Method Details

.constructor(builtin, this, value) ⇒ Object



8
9
10
# File 'lib/ruby_run_js/object_methods/js_boolean.rb', line 8

def constructor(builtin, this, value)
  to_boolean(value)
end

.constructor_new(builtin, this, value) ⇒ Object



12
13
14
# File 'lib/ruby_run_js/object_methods/js_boolean.rb', line 12

def constructor_new(builtin, this, value)
  builtin.new_boolean(value)
end

.prototype_toString(builtin, this) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/ruby_run_js/object_methods/js_boolean.rb', line 16

def prototype_toString(builtin, this)
  if this.js_class != 'Boolean'
    raise make_error('TypeError', 'Boolean.prototype.toString is not generic')
  end
  if this.js_type == :Object
    this = this.value
  end
  this ? 'true' : 'false'
end

.prototype_valueOf(builtin, this) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/ruby_run_js/object_methods/js_boolean.rb', line 26

def prototype_valueOf(builtin, this)
  if this.js_class != 'Boolean'
    raise make_error('TypeError', 'Boolean.prototype.valueOf is not generic')
  end
  if this.js_type == :Object
    this = this.value
  end
  this
end