Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/comet-html/utils.rb
Instance Method Summary collapse
Instance Method Details
#camelize ⇒ Object
2 3 4 5 |
# File 'lib/comet-html/utils.rb', line 2 def camelize parts = self.split(/_+|-+|\W+/) (parts.map do |part| part.capitalize end).join end |
#dasherize ⇒ Object
7 8 9 10 11 12 |
# File 'lib/comet-html/utils.rb', line 7 def dasherize tmp = self.gsub(/([A-Z]+)/, '_\1') parts = tmp.split(/_+|-+|\W+/) parts.select! {|item| item != ""} (parts.map do |part| part.downcase end).join '-' end |