Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/mystic/extensions.rb
Instance Method Summary collapse
- #capitalize_first! ⇒ Object
- #desnake ⇒ Object
- #escape ⇒ Object (also: #sanitize)
- #sql_terminate ⇒ Object
- #truncate(len) ⇒ Object
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 |
#desnake ⇒ Object
18 19 20 |
# File 'lib/mystic/extensions.rb', line 18 def desnake downcase.split("_").map(&:capitalize)*' ' end |
#escape ⇒ Object Also known as: sanitize
22 23 24 |
# File 'lib/mystic/extensions.rb', line 22 def escape Mystic.escape(self).untaint end |
#sql_terminate ⇒ Object
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 |