Class: Oversetter::Glosbe::Example
- Inherits:
-
Object
- Object
- Oversetter::Glosbe::Example
- Defined in:
- lib/oversetter/glosbe/example.rb
Overview
Fetches examples from Glosbe.
Instance Method Summary collapse
Instance Method Details
#get_ex(search, params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/oversetter/glosbe/example.rb', line 10 def get_ex(search, params) func, result = 'tm', nil tran = Oversetter::Glosbe.new result = tran.get_word(search, func, params, result) result = MultiJson.load(result) if result != nil && result['result'] == 'ok' st = { 'searchterm' => URI.decode(search) } type = { 'type' => 'example' } Oversetter.tofile(st) Oversetter.tofile(type) ex = result['examples'] x, y, label = 0, ex.length - 1, 'Examples' Oversetter.label(label) while x <= y item = ex[x] s = { 'source' => item['first'] } t = { 'target' => item['second'] } puts Rainbow("Source|#{item['first']}|Target|#{item['second']}").bright Oversetter.tofile(s) Oversetter.tofile(t) x += 1 end end end |