Module: Alexandria::Helpers

Extended by:
Helpers
Included in:
Helpers
Defined in:
lib/alexandria/helpers.rb

Instance Method Summary collapse

Instance Method Details

#book_path(author, title) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/alexandria/helpers.rb', line 10

def book_path(author, title)
  normal_author = normalise(author)
  normal_title = normalise(title)
  path = File.join(normal_author, normal_title)

  File.join LIB_ROOT, path
end

#normalise(title) ⇒ Object



6
7
8
# File 'lib/alexandria/helpers.rb', line 6

def normalise(title)
  title.gsub(' ', '_').gsub(/\W/, '').gsub('_', '-').downcase
end