Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/codemodels/monkey_patching.rb
Instance Method Summary collapse
- #proper_capitalize ⇒ Object
- #proper_uncapitalize ⇒ Object
- #remove_postfix(postfix) ⇒ Object
- #remove_prefix(prefix) ⇒ Object
Instance Method Details
#proper_capitalize ⇒ Object
22 23 24 |
# File 'lib/codemodels/monkey_patching.rb', line 22 def proper_capitalize self[0, 1].upcase + self[1..-1] end |
#proper_uncapitalize ⇒ Object
26 27 28 |
# File 'lib/codemodels/monkey_patching.rb', line 26 def proper_uncapitalize self[0, 1].downcase + self[1..-1] end |
#remove_postfix(postfix) ⇒ Object
12 13 14 15 |
# File 'lib/codemodels/monkey_patching.rb', line 12 def remove_postfix(postfix) raise "'#{self}'' have not the right postfix '#{postfix}'" unless end_with?(postfix) self[0..-(1+postfix.length)] end |
#remove_prefix(prefix) ⇒ Object
17 18 19 20 |
# File 'lib/codemodels/monkey_patching.rb', line 17 def remove_prefix(prefix) raise "'#{self}'' have not the right prefix '#{prefix}'" unless start_with?(prefix) self[prefix.length..-1] end |