class Ve::HTTPInterface
Public Class Methods
new(language, config = {})
click to toggle source
# File lib/ve.rb, line 70 def initialize(language, config = {}) @language = language @base_url = config[:url] end
Public Instance Methods
method_missing(function, *args)
click to toggle source
# File lib/ve.rb, line 75 def method_missing(function, *args) url = "#{@base_url}/#{@language}/#{function}" uri = URI.parse(url) response = Net::HTTP.post_form(uri, {:text => args[0]}) data = JSON.parse(response.body) result = [] data.each do |obj| # TODO: Support transliterations case obj['_class'] when 'Word' result << Ve::Word.new(obj['word'], obj['lemma'], obj['part_of_speech'], obj['tokens'], obj['extra'], obj['info']) end end result end