Class: Lingo::Web

Inherits:
App
  • Object
show all
Defined in:
lib/lingo/web.rb

Constant Summary collapse

LINGO =
Hash.nest { |k| Lingo.call(cfg, ['-l', k]) }

Instance Method Summary collapse

Methods inherited from App

init_app, parse_options, rackup, #to_json

Instance Method Details

#doitObject



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/lingo/web.rb', line 106

def doit
  @r = LINGO[@l].talk(@q) { |_| _ } if @q && !@q.empty?

  case params[:f]
    when 'json'
      to_json(@q, @r)
    when 'text'
      @r &&  @r.join("\n")
    else
      @r &&= @r.join("\n")
      erb :index
  end
end