Class: Juvet::String
- Inherits:
-
Object
- Object
- Juvet::String
- Defined in:
- lib/juvet/string.rb
Instance Method Summary collapse
- #classify ⇒ Object
-
#initialize(string) ⇒ String
constructor
A new instance of String.
- #underscore ⇒ Object
Constructor Details
#initialize(string) ⇒ String
Returns a new instance of String.
3 4 5 |
# File 'lib/juvet/string.rb', line 3 def initialize(string) @string = string.to_s end |
Instance Method Details
#classify ⇒ Object
7 8 9 |
# File 'lib/juvet/string.rb', line 7 def classify string.split("_").map{ |w| w.capitalize }.join end |
#underscore ⇒ Object
11 12 13 14 |
# File 'lib/juvet/string.rb', line 11 def underscore modified = string.gsub(/(.)([A-Z])/,'\1_\2') modified.downcase end |