Class: PageMagic::Watcher
Overview
class WatchedElementDefinition - Contains the specification the for checking if an subject has changed
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#observed_value ⇒ Object
readonly
Returns the value of attribute observed_value.
Instance Method Summary collapse
-
#==(other) ⇒ Boolen
True of the candiate is equal ot this one.
-
#check ⇒ PageMagic::Watcher
check current value of watched element.
-
#initialize(name, context:, &block) ⇒ Watcher
constructor
A new instance of Watcher.
Constructor Details
#initialize(name, context:, &block) ⇒ Watcher
Returns a new instance of Watcher.
13 14 15 16 17 |
# File 'lib/page_magic/watcher.rb', line 13 def initialize(name, context:, &block) @name = name @context = context @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/page_magic/watcher.rb', line 6 def block @block end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/page_magic/watcher.rb', line 6 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/page_magic/watcher.rb', line 6 def name @name end |
#observed_value ⇒ Object (readonly)
Returns the value of attribute observed_value.
6 7 8 |
# File 'lib/page_magic/watcher.rb', line 6 def observed_value @observed_value end |
Instance Method Details
#==(other) ⇒ Boolen
Returns true of the candiate is equal ot this one.
30 31 32 33 34 |
# File 'lib/page_magic/watcher.rb', line 30 def ==(other) other.is_a?(Watcher) && name == other.name && block == other.block end |
#check ⇒ PageMagic::Watcher
check current value of watched element. The result of the check can be accessed by calling #last if a block was specified to the constructor then this will be executed.
23 24 25 26 |
# File 'lib/page_magic/watcher.rb', line 23 def check @observed_value = context.instance_eval(&block) self end |