Class: String

Inherits:
Object show all
Defined in:
lib/operawatir/preferences.rb

Instance Method Summary collapse

Instance Method Details

#keyizeObject

Translates a previously keyized Opera preferences method string into an Opera preferences key string. This is done by replacing underscores with spaces and capitalizing each word in the string.

The method extends the String object and can be called as a regular method on any string in Ruby.



26
27
28
# File 'lib/operawatir/preferences.rb', line 26

def keyize
  self.gsub(/_/, ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
end

#methodizeObject

Translates an Opera preferences key string into a Ruby method name. It will remove tabs and spaces at beginning of string, replace further spaces with an underscore and make the string lower-case.

The method extends the String object and can be called as a regular method on any string in Ruby.



13
14
15
# File 'lib/operawatir/preferences.rb', line 13

def methodize
  self.gsub(/^\\t(\s+)/, '').gsub(/\s+/, '_').downcase
end