Module: StringExtensions
- Defined in:
- lib/plugins/string_extensions/lib/string_extensions.rb
Instance Method Summary collapse
Instance Method Details
#symbolize ⇒ Object
2 3 4 |
# File 'lib/plugins/string_extensions/lib/string_extensions.rb', line 2 def symbolize self.gsub(/[^A-Za-z0-9]+/, "_").gsub(/(^_+|_+$)/, "").underscore.to_sym end |
#titlecase ⇒ Object
6 7 8 |
# File 'lib/plugins/string_extensions/lib/string_extensions.rb', line 6 def titlecase self.gsub(/((?:^|\s)[a-z])/) { $1.upcase } end |
#to_name(last_part = '') ⇒ Object
10 11 12 |
# File 'lib/plugins/string_extensions/lib/string_extensions.rb', line 10 def to_name(last_part = '') self.underscore.gsub('/', ' ').humanize.titlecase.gsub(/\s*#{last_part}$/, '') end |