Class: OperaWatir::Preferences::Section

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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`.

Examples:


browser.preferences.interface_colors.background
# will return the “Background” entry in section “Interface Colors”

Parameters:

  • method

    method to look up in section

Returns:

  • (Object)

    a Preferences::Section::Key (entry) object



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

#driverObject

Returns the value of attribute driver.



252
253
254
# File 'lib/operawatir/preferences.rb', line 252

def driver
  @driver
end

#keyObject

Returns the value of attribute key.



252
253
254
# File 'lib/operawatir/preferences.rb', line 252

def key
  @key
end

#methodObject

Returns the value of attribute method.



252
253
254
# File 'lib/operawatir/preferences.rb', line 252

def method
  @method
end

#parentObject

Returns the value of attribute parent.



252
253
254
# File 'lib/operawatir/preferences.rb', line 252

def parent
  @parent
end

Instance Method Details

#eachObject



268
269
270
271
# File 'lib/operawatir/preferences.rb', line 268

def each
  return unless block_given?
  _keys.each { |k| yield k }
end