Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/wara.rb
Instance Method Summary collapse
Instance Method Details
#to_camel ⇒ Object
13 14 15 16 17 18 |
# File 'lib/wara.rb', line 13 def to_camel self.split(/[_\s]+/).map{|i| a,b,c = i.split(/^(.)/) "#{b.upcase}#{c}" }.join('') end |
#to_scamel ⇒ Object
19 20 21 22 |
# File 'lib/wara.rb', line 19 def to_scamel s = self.to_camel s[0].downcase + s[1..-1] end |
#to_snake ⇒ Object
7 8 9 10 11 12 |
# File 'lib/wara.rb', line 7 def to_snake ptn = /[A-Z\s]*[^A-Z]*/ self.scan(ptn).map{|i| i.gsub(/[\s:]+/,'_').downcase }.join('_').gsub(/__+/,'_').sub(/_$/,'') end |