Class: String
Instance Method Summary collapse
-
#keyize ⇒ Object
Translates a previously keyized Opera preferences method string into an Opera preferences key string.
-
#methodize ⇒ Object
Translates an Opera preferences key string into a Ruby method name.
Instance Method Details
#keyize ⇒ Object
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 |
#methodize ⇒ Object
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 |