Class: StringHelper
- Inherits:
-
Object
- Object
- StringHelper
- Defined in:
- lib/string_helper.rb
Class Method Summary collapse
Class Method Details
.to_title(s) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/string_helper.rb', line 3 def self.to_title(s) small_words = %w{a an and the or for of nor} title_words = [] s.split('_').each_with_index do |word, i| word.capitalize! unless small_words.include?(word) word.capitalize! if i == 0 title_words.push(word) end title_words.join(' ') end |