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



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/webkit_remote/client/runtime.rb', line 473

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



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

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



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

def enumerable
  @enumerable
end

#nameString (readonly)

Returns the property’s name.

Returns:

  • (String)

    the property’s name



444
445
446
# File 'lib/webkit_remote/client/runtime.rb', line 444

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



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

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



450
451
452
# File 'lib/webkit_remote/client/runtime.rb', line 450

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



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

def writable
  @writable
end

Instance Method Details

#inspectObject

Debugging output.



492
493
494
495
496
497
498
# File 'lib/webkit_remote/client/runtime.rb', line 492

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