Class: IdiomList

Inherits:
Object
  • Object
show all
Defined in:
lib/words_and_idioms/zz - idioms.rb

Constant Summary collapse

@@word_url =
"http://www.macmillandictionary.com/us/open-dictionary/latestEntries.html"
@@html =
open(@@word_url)
@@doc =
Nokogiri::HTML(@@html)
@@all =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIdiomList

Returns a new instance of IdiomList.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/words_and_idioms/zz - idioms.rb', line 8

def initialize
  idiom_array = []
  @@doc.css(" #openEntries .openEntry h3").each {|heading| idiom_array << heading.text}
  definition_array = []
  @@doc.css(" #openEntries .openEntry .openDef").each {|definition| definition_array << definition.text}
  idiom_hash = Hash[idiom_array.zip definition_array]
  idiom_hash.each do |k,v|
    idiom = {"#{k}" => v}
    @@all << idiom
  end
end

Class Method Details

.allObject



20
21
22
# File 'lib/words_and_idioms/zz - idioms.rb', line 20

def self.all
  @@all
end