Class: Lingvo::Parsers::Lingualeo

Inherits:
Object
  • Object
show all
Defined in:
lib/lingvo/parsers/lingualeo_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Lingualeo

Returns a new instance of Lingualeo.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lingvo/parsers/lingualeo_parser.rb', line 8

def initialize(path)
  @words = []
  resource = Nokogiri::HTML(File.open(path))
  resource.xpath('//body/table/tbody/tr').each do |tr|
    tds = tr.css('td')

    next if tds[0].nil?
    @words << {
      eng: tds[1].content.strip,
      transcr: tds[2].content.strip,
      ru: tds[3].content.strip,
    }
  end
end

Instance Attribute Details

#wordsObject (readonly)

Returns the value of attribute words.



6
7
8
# File 'lib/lingvo/parsers/lingualeo_parser.rb', line 6

def words
  @words
end