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