6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/words_and_idioms/idiom_scraper.rb', line 6
def self.constructor
counter = 0
@@doc.search(".openEntry").each do |node|
name = @@doc.search(".openEntry")[counter].css("a").text
definition = @@doc.search(".openEntry")[counter].css(".openDef").text
if @@doc.search(".openEntry")[counter].css(".openEx").text != ""
usage = @@doc.search(".openEntry")[counter].css(".openEx").text
elsif @@doc.search(".openEntry")[counter].css(".openEx").text == ""
usage = "It looks like nobody has submitted a sentence yet. Maybe you could write one!"
end
Idiom.new(name, definition, usage)
counter += 1
end
end
|