Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_camelObject



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_scamelObject



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_snakeObject



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