Class: Rack::Directory::DirectoryBody

Inherits:
Struct
  • Object
show all
Defined in:
lib/rack/directory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filesObject

Returns the value of attribute files


44
45
46
# File 'lib/rack/directory.rb', line 44

def files
  @files
end

#pathObject

Returns the value of attribute path


44
45
46
# File 'lib/rack/directory.rb', line 44

def path
  @path
end

#rootObject

Returns the value of attribute root


44
45
46
# File 'lib/rack/directory.rb', line 44

def root
  @root
end

Instance Method Details

#eachObject


45
46
47
48
49
50
# File 'lib/rack/directory.rb', line 45

def each
  show_path = Rack::Utils.escape_html(path.sub(/^#{root}/, ''))
  listings = files.map{|f| DIR_FILE % DIR_FILE_escape(*f) } * "\n"
  page = DIR_PAGE % [ show_path, show_path, listings ]
  page.each_line{|l| yield l }
end