Class: WebkitRemote::Client::JsProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/webkit_remote/client/runtime.rb

Overview

A property of a remote JavaScript object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_property, owner) ⇒ JsProperty

Returns a new instance of JsProperty.

Parameters:

  • raw_property (Hash<String, Object>)

    a PropertyDescriptor instance, according to the Webkit remote debugging protocol; this is an item in the array returned by the ‘Runtime.getProperties’ RPC call

  • owner (WebkitRemote::Client::JsObject)

    the object that this property belongs to



477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/webkit_remote/client/runtime.rb', line 477

def initialize(raw_property, owner)
  # NOTE: these are only used at construction time
  client = owner.client
  group_name = owner.group.name

  @owner = owner
  @name = raw_property['name']
  @configurable = !!raw_property['configurable']
  @enumerable = !!raw_property['enumerable']
  @writable = !!raw_property['writable']
  @js_getter = raw_property['get'] && WebkitRemote::Client::JsObject.for(
      raw_property['get'], client, group_name)
  @js_setter = raw_property['set'] && WebkitRemote::Client::JsObject.for(
      raw_property['set'], client, group_name)
  @value = raw_property['value'] && WebkitRemote::Client::JsObject.for(
      raw_property['value'], client, group_name)
end

Instance Attribute Details

#configurableBoolean (readonly) Also known as: configurable?

Returns true if JavaScript code can remove this property.

Returns:

  • (Boolean)

    true if JavaScript code can remove this property



457
458
459
# File 'lib/webkit_remote/client/runtime.rb', line 457

def configurable
  @configurable
end

#enumerableBoolean (readonly) Also known as: enumerable?

Returns true if JavaScript code can enumerate this property.

Returns:

  • (Boolean)

    true if JavaScript code can enumerate this property



461
462
463
# File 'lib/webkit_remote/client/runtime.rb', line 461

def enumerable
  @enumerable
end

#nameString (readonly)

Returns the property’s name.

Returns:

  • (String)

    the property’s name



448
449
450
# File 'lib/webkit_remote/client/runtime.rb', line 448

def name
  @name
end

#ownerWebkitRemote::JsObject (readonly)

Returns the object that this property belongs to.

Returns:

  • (WebkitRemote::JsObject)

    the object that this property belongs to



470
471
472
# File 'lib/webkit_remote/client/runtime.rb', line 470

def owner
  @owner
end

#valueWebkitRemote::Client::JsObject, ... (readonly)

Returns a Ruby wrapper for the property’s value; primitives get wrapped by standard Ruby classes, and objects get wrapped by JsObject instances.

Returns:

  • (WebkitRemote::Client::JsObject, Boolean, Number, String, nil)

    a Ruby wrapper for the property’s value; primitives get wrapped by standard Ruby classes, and objects get wrapped by JsObject instances



454
455
456
# File 'lib/webkit_remote/client/runtime.rb', line 454

def value
  @value
end

#writableBoolean (readonly) Also known as: writable?

Returns true if JavaScript code can change this property’s value.

Returns:

  • (Boolean)

    true if JavaScript code can change this property’s value



465
466
467
# File 'lib/webkit_remote/client/runtime.rb', line 465

def writable
  @writable
end

Instance Method Details

#inspectObject

Debugging output.



496
497
498
499
500
501
502
# File 'lib/webkit_remote/client/runtime.rb', line 496

def inspect
  result = self.to_s
  result[-1, 0] =
      " name=#{@name.inspect} configurable=#{@configurable} " +
      "enumerable=#{@enumerable} writable=#{@writable}"
  result
end