Class: Katakanaize

Inherits:
Object
  • Object
show all
Defined in:
lib/katakanaize.rb,
lib/katakanaize/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Katakanaize

Returns a new instance of Katakanaize.



7
8
9
# File 'lib/katakanaize.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/katakanaize.rb', line 11

def call(env)
  response = @app.call(env)
  body = response[2][0]
  new_body = NKF.nkf('-wh2', body)
  new_response = Rack::Response.new do |res|
    res.status = 200
    res['Content-Type'] = 'text/html'
    res.write new_body
  end
  new_response.finish
end