Class: Rack::Directory::DirectoryBody
- Inherits:
-
Struct
- Object
- Struct
- Rack::Directory::DirectoryBody
- Defined in:
- lib/rack/directory.rb
Overview
Body class for directory entries, showing an index page with links to each file.
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#path ⇒ Object
Returns the value of attribute path.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
-
#each {|DIR_PAGE_HEADER % [ show_path, show_path ]| ... } ⇒ Object
Yield strings for each part of the directory entry.
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files
51 52 53 |
# File 'lib/rack/directory.rb', line 51 def files @files end |
#path ⇒ Object
Returns the value of attribute path
51 52 53 |
# File 'lib/rack/directory.rb', line 51 def path @path end |
#root ⇒ Object
Returns the value of attribute root
51 52 53 |
# File 'lib/rack/directory.rb', line 51 def root @root end |
Instance Method Details
#each {|DIR_PAGE_HEADER % [ show_path, show_path ]| ... } ⇒ Object
Yield strings for each part of the directory entry
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rack/directory.rb', line 53 def each show_path = Utils.escape_html(path.sub(/^#{root}/, '')) yield(DIR_PAGE_HEADER % [ show_path, show_path ]) unless path.chomp('/') == root yield(DIR_FILE % DIR_FILE_escape(files.call('..'))) end Dir.foreach(path) do |basename| next if basename.start_with?('.') next unless f = files.call(basename) yield(DIR_FILE % DIR_FILE_escape(f)) end yield(DIR_PAGE_FOOTER) end |