123456789_123456789_123456789_123456789_123456789_

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

Instance Method Summary

Constructor Details

.newMountTable

[ GitHub ]

  
# 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 ]

  
# File 'lib/webrick/httpserver.rb', line 244

def []=(dir, val)
  dir = normalize(dir)
  @tab[dir] = val
  compile
  val
end

#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 ]

  
# File 'lib/webrick/httpserver.rb', line 251

def delete(dir)
  dir = normalize(dir)
  res = @tab.delete(dir)
  compile
  res
end

#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