class Lingo::Srv

Constants

LINGO
SRC_SEP

Public Instance Methods

doit() click to toggle source
# File lib/lingo/srv.rb, line 49
def doit
  to_json(q = params[:q], case q
    when String then talk(q)
    when Array  then q.inject({}) { |h, k| h[k] = talk(k); h }
  end)
end
talk(q) click to toggle source
# File lib/lingo/srv.rb, line 56
def talk(q)
  r = LINGO.talk(q) unless q.empty?
  return r unless r && SRC_SEP

  s = Hash.array

  r.each { |t|
    a, b = t.split(SRC_SEP, 2)
    s[b] << a
  }

  ENV['LINGO_NO_SORT'] ? s.to_a : s
end