class Annyong::Directory

Constants

DIR_FILE
DIR_PAGE

Public Instance Methods

each() { |content| ... } click to toggle source
# File lib/annyong/directory.rb, line 28
def each
  page = DIR_PAGE % [html_title, page_title, files]
  page.each_line { |content| yield content }
end

Private Instance Methods

files() click to toggle source
# File lib/annyong/directory.rb, line 47
def files
  @files.map { |file| DIR_FILE % file } * "\n"
end
html_title() click to toggle source
# File lib/annyong/directory.rb, line 35
def html_title
  path = @path.sub(/^#{@root}/,'').gsub(/\/$/, '')
  File.basename(FileUtils.pwd) + path
end
page_title() click to toggle source
# File lib/annyong/directory.rb, line 40
def page_title
  parts = html_title.split('/')
  parts.each_with_index.map do |item, index|
    "<a href='#{'../' * (parts.length - index - 1)}'>#{item}</a>"
  end.join(' / ')
end