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
25 26 27 |
# File 'lib/codemodels/monkey_patching.rb', line 25 def proper_capitalize self[0, 1].upcase + self[1..-1] end |
#proper_uncapitalize ⇒ Object
29 30 31 |
# File 'lib/codemodels/monkey_patching.rb', line 29 def proper_uncapitalize self[0, 1].downcase + self[1..-1] end |
#remove_postfix(postfix) ⇒ Object
15 16 17 18 |
# File 'lib/codemodels/monkey_patching.rb', line 15 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
20 21 22 23 |
# File 'lib/codemodels/monkey_patching.rb', line 20 def remove_prefix(prefix) raise "'#{self}'' have not the right prefix '#{prefix}'" unless start_with?(prefix) self[prefix.length..-1] end |