Class: String
Instance Method Summary collapse
- #dasherize ⇒ Object
- #includes_one_of?(arr) ⇒ Boolean
- #spacify ⇒ Object
- #titlecase ⇒ Object
- #titleize ⇒ Object
- #underline ⇒ Object
Instance Method Details
#dasherize ⇒ Object
17 18 19 |
# File 'lib/helpers/string.rb', line 17 def dasherize self.gsub(" ", "-").gsub("_", "-") end |
#includes_one_of?(arr) ⇒ Boolean
25 26 27 28 29 30 31 |
# File 'lib/helpers/string.rb', line 25 def includes_one_of?(arr) tr = false arr.each do |el| tr ||= self.include?(el) end tr end |
#spacify ⇒ Object
13 14 15 |
# File 'lib/helpers/string.rb', line 13 def spacify self.gsub("-", " ").gsub("_", " ") end |
#titlecase ⇒ Object
5 6 7 |
# File 'lib/helpers/string.rb', line 5 def titlecase self.downcase.spacify.split(" ").collect {|str| str.capitalize}.join(" ") end |
#titleize ⇒ Object
9 10 11 |
# File 'lib/helpers/string.rb', line 9 def titleize titlecase end |
#underline ⇒ Object
21 22 23 |
# File 'lib/helpers/string.rb', line 21 def underline self.gsub(/\W/, "_") end |