class Rack::Lobster - rack-1.6.4 Documentation

# class Rack::Lobster

Paste has a Pony, Rack has a Lobster!

### Constants

LambdaLobster
LobsterString

### Public Instance Methods

call(env) click to toggle source

    # File lib/rack/lobster.rb, line 32
    def call(env)
      req = Request.new(env)
      if req.GET["flip"] == "left"
        lobster = LobsterString.split("\n").map do |line|
          line.ljust(42).reverse.
            gsub('\', 'TEMP').
            gsub('/', '\').
            gsub('TEMP', '/').
            gsub('{','}').
            gsub('(',')')
        end.join("\n")
        href = "?flip=right"
      elsif req.GET["flip"] == "crash"
        raise "Lobster crashed"
      else
        lobster = LobsterString
        href = "?flip=left"
      end

      res = Response.new
      res.write "<title>Lobstericious!</title>"
      res.write "<pre>"
      res.write lobster
      res.write "</pre>"
      res.write "<p><a href='#{href}'>flip!</a></p>"
      res.write "<p><a href='?flip=crash'>crash!</a></p>"
      res.finish
    end