Sha256: fa5bc2230772f176656984280036425a31072812aa8f7ebca1f8e9d3ba727629

Contents?: true

Size: 337 Bytes

Versions: 12

Compression:

Stored size: 337 Bytes

Contents

class StringHelper

  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

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
markdown_helper-2.5.4 lib/string_helper.rb
markdown_helper-2.5.3 lib/string_helper.rb
markdown_helper-2.5.2 lib/string_helper.rb
markdown_helper-2.5.1 lib/string_helper.rb
markdown_helper-2.5.0 lib/string_helper.rb
markdown_helper-2.4.0 lib/string_helper.rb
markdown_helper-2.3.0 lib/string_helper.rb
markdown_helper-2.2.0 lib/string_helper.rb
markdown_helper-2.1.0 lib/string_helper.rb
markdown_helper-2.0.0 lib/string_helper.rb
markdown_helper-1.9.9 lib/string_helper.rb
markdown_helper-1.9.5 lib/string_helper.rb