Class: Rack::GoogleImage

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-middleware-google-image.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ GoogleImage

Returns a new instance of GoogleImage.



6
7
8
# File 'lib/rack-middleware-google-image.rb', line 6

def initialize(app, options = {})
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/rack-middleware-google-image.rb', line 10

def call(env)
  status, headers, response = @app.call(env)

  if env['REQUEST_PATH'].match(/(.*)\.jpg$/)
    response = search_image(response, $1)
    [status, headers, response]
  end

  [status, headers, response]
end