Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/extraloop/support.rb

Instance Method Summary collapse

Instance Method Details

#camel_caseObject



20
21
22
# File 'lib/extraloop/support.rb', line 20

def camel_case
  self.gsub(/^.|_./) { |chars| chars.split("").last.upcase }
end

#capitalize_firstObject



17
18
19
# File 'lib/extraloop/support.rb', line 17

def capitalize_first
  self[0].upcase + self[1, size]
end

#snake_caseObject



24
25
26
27
28
29
30
# File 'lib/extraloop/support.rb', line 24

def snake_case
  self.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end