Class: OperaWatir::Preferences::Section::Key

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/operawatir/preferences.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, raw_key) ⇒ Key

Returns a new instance of Key.



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/operawatir/preferences.rb', line 311

def initialize(parent, raw_key)
  self.parent, self.driver = parent, parent.driver
  self.method, self.key = raw_key.first.methodize, raw_key.first
  raw_data = raw_key[1].to_s

  raw_data =~ /^type: ([A-Z]+)$/
  self.type = $1.to_s.capitalize

  raw_data =~ /^value: \"(.*)\"$/
  @value = $1.to_s

  # Ruby doesn't support attr_accessor's with question mark in their
  # name.
  raw_data =~ /^enabled: (true|false)$/
  @enabled = $1.truthy?
end

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



309
310
311
# File 'lib/operawatir/preferences.rb', line 309

def driver
  @driver
end

#keyObject

Returns the value of attribute key.



309
310
311
# File 'lib/operawatir/preferences.rb', line 309

def key
  @key
end

#methodObject

Returns the value of attribute method.



309
310
311
# File 'lib/operawatir/preferences.rb', line 309

def method
  @method
end

#parentObject

Returns the value of attribute parent.



309
310
311
# File 'lib/operawatir/preferences.rb', line 309

def parent
  @parent
end

#typeObject

Returns the value of attribute type.



309
310
311
# File 'lib/operawatir/preferences.rb', line 309

def type
  @type
end

#valueObject

Returns the value of attribute value.



309
310
311
# File 'lib/operawatir/preferences.rb', line 309

def value
  @value
end

Instance Method Details

#defaultString

Returns key’s default value.

Returns:

  • (String)

    the default value of the key



356
357
358
# File 'lib/operawatir/preferences.rb', line 356

def default
  @default ||= driver.getDefaultPref parent.key, key
end

#default!String

Returns and sets the default value of the key.

Returns:

  • (String)

    the default value of the key



366
367
368
# File 'lib/operawatir/preferences.rb', line 366

def default!
  self.value=(default)
end

#enabled?Boolean

Whether the current key entry is enabled inside Opera or not.

Returns:

  • (Boolean)

    true if enabled, false if otherwise



334
335
336
# File 'lib/operawatir/preferences.rb', line 334

def enabled?
  !!@enabled
end