Class: OperaWatir::Preferences::Section
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/operawatir/preferences.rb
Overview
OperaWatir::Preferences::Section represents a section in Opera configuration.
Defined Under Namespace
Classes: Key
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#key ⇒ Object
Returns the value of attribute key.
-
#method ⇒ Object
Returns the value of attribute method.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(parent, raw_section) ⇒ Section
constructor
A new instance of Section.
-
#method_missing(method) ⇒ Object
When calling Preferences::Section#any_method_name, the ‘any_method_name` will be caught by this method.
Constructor Details
#initialize(parent, raw_section) ⇒ Section
Returns a new instance of Section.
254 255 256 257 258 259 |
# File 'lib/operawatir/preferences.rb', line 254 def initialize(parent, raw_section) self.parent, self.driver = parent, parent.driver self.method, self.key = raw_section.first.methodize, raw_section.first @_keys = raw_section[1].map { |k| Key.new(self, k) }.sort_by { |k| k.key } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
When calling Preferences::Section#any_method_name, the ‘any_method_name` will be caught by this method.
This is the standard way of looking up preference entries. ‘any_method_name` should be replaced by a methodized version of the entry as it appears in the Opera preferences list which you can find at `opera:config`.
291 292 293 294 295 296 297 |
# File 'lib/operawatir/preferences.rb', line 291 def method_missing(method) method = method.to_s if _keys.any? { |k| k.method == method } _keys.find { |k| k.method == method } end end |
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
252 253 254 |
# File 'lib/operawatir/preferences.rb', line 252 def driver @driver end |
#key ⇒ Object
Returns the value of attribute key.
252 253 254 |
# File 'lib/operawatir/preferences.rb', line 252 def key @key end |
#method ⇒ Object
Returns the value of attribute method.
252 253 254 |
# File 'lib/operawatir/preferences.rb', line 252 def method @method end |
#parent ⇒ Object
Returns the value of attribute parent.
252 253 254 |
# File 'lib/operawatir/preferences.rb', line 252 def parent @parent end |
Instance Method Details
#each ⇒ Object
268 269 270 271 |
# File 'lib/operawatir/preferences.rb', line 268 def each return unless block_given? _keys.each { |k| yield k } end |