Class: Rack::Directory::DirectoryBody

Inherits:
Struct show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/directory.rb

Overview

Body class for directory entries, showing an index page with links to each file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#as_json

Instance Attribute Details

#filesObject

Returns the value of attribute files

Returns:

  • (Object)

    the current value of files



45
46
47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/directory.rb', line 45

def files
  @files
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



45
46
47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/directory.rb', line 45

def path
  @path
end

#rootObject

Returns the value of attribute root

Returns:

  • (Object)

    the current value of root



45
46
47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/directory.rb', line 45

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

Yields:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/directory.rb', line 47

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