Sha256: f5f3a9d94af875786bf81920affde9960015dde95ac2809df97e9b8efad8cafb

Contents?: true

Size: 589 Bytes

Versions: 1

Compression:

Stored size: 589 Bytes

Contents

module Pubbee
  
  #extending ActiveSupport:Inflector titleize method to downcase articles 
  def book_titleize(book_name)
    articles = ['a', 'an', 'the', 'of', 'and']
    book_titleize = []
    begin
      book_name.split(/_| /).each_with_index do |n, ii|
        if articles.include?(n) && ii == 0
          book_titleize << n.capitalize + " "
        elsif articles.include?(n) && ii > 0
          book_titleize << n.downcase + " "
        else
          book_titleize << n.capitalize + " "
        end
      end
      book_titleize
    rescue
      book_name
    end
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pubbee-0.0.0 lib/pubbee.rb