Class: WEBrick::HTTPServer::MountTable
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/webrick/httpserver.rb |
Overview
Mount table for the path a servlet is mounted on in the directory space of the server. Users of ::WEBrick can only access this indirectly via #mount, #unmount and #search_servlet
Class Method Summary
- .new ⇒ MountTable constructor
Instance Method Summary
- #[](dir)
- #[]=(dir, val)
- #delete(dir)
- #scan(path)
- #compile private
- #normalize(dir) private
Constructor Details
.new ⇒ MountTable
# File 'lib/webrick/httpserver.rb', line 234
def initialize @tab = Hash.new compile end
Instance Method Details
#[](dir)
[ GitHub ]# File 'lib/webrick/httpserver.rb', line 239
def [](dir) dir = normalize(dir) @tab[dir] end
#[]=(dir, val)
[ GitHub ]#compile (private)
[ GitHub ]# File 'lib/webrick/httpserver.rb', line 265
def compile k = @tab.keys k.sort! k.reverse! k.collect!{|path| Regexp.escape(path) } @scanner = Regexp.new("\\A(" + k.join("|") +")(?=/|\\z)") end
#delete(dir)
[ GitHub ]#normalize(dir) (private)
[ GitHub ]# File 'lib/webrick/httpserver.rb', line 273
def normalize(dir) ret = dir ? dir.dup : "" ret.sub!(%r|/+\z|, "") ret end
#scan(path)
[ GitHub ]# File 'lib/webrick/httpserver.rb', line 258
def scan(path) @scanner =~ path [ $&, $' ] end