Class: Lingvo::Parsers::Lingualeo
- Inherits:
-
Object
- Object
- Lingvo::Parsers::Lingualeo
- Defined in:
- lib/lingvo/parsers/lingualeo_parser.rb
Instance Method Summary collapse
-
#initialize(path, &block) ⇒ Lingualeo
constructor
A new instance of Lingualeo.
Constructor Details
#initialize(path, &block) ⇒ Lingualeo
Returns a new instance of Lingualeo.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/lingvo/parsers/lingualeo_parser.rb', line 6 def initialize(path, &block) resource = Nokogiri::HTML File.open(path) resource.xpath('//body/table/tbody/tr').each do |tr| tds = tr.css('td') next if tds[0].nil? eng = tds[1].content.strip transcr = tds[2].content.strip ru = tds[3].content.strip if eng.size < 20 && transcr.size < 20 && ru.size < 20 block.call eng: eng, transcr: transcr, ru: ru end end end |