Class: String

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

Instance Method Summary collapse

Instance Method Details

#capitalize_first!Object



14
15
16
# File 'lib/mystic/extensions.rb', line 14

def capitalize_first!
  self[0] = self[0].upcase
end

#desnakeObject



18
19
20
# File 'lib/mystic/extensions.rb', line 18

def desnake
  downcase.split("_").map(&:capitalize)*' '
end

#escapeObject Also known as: sanitize



22
23
24
# File 'lib/mystic/extensions.rb', line 22

def escape
  Mystic.escape(self).untaint
end

#sql_terminateObject



32
33
34
35
# File 'lib/mystic/extensions.rb', line 32

def sql_terminate
	return self + ";" unless dup.strip.end_with? ";"
	self
end

#truncate(len) ⇒ Object



28
29
30
# File 'lib/mystic/extensions.rb', line 28

def truncate(len)
	self[0..len-1]
end