Class: IdiomList
- Inherits:
-
Object
- Object
- IdiomList
- Defined in:
- lib/words_and_idioms/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
-
#initialize ⇒ IdiomList
constructor
A new instance of IdiomList.
Constructor Details
#initialize ⇒ IdiomList
Returns a new instance of IdiomList.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/words_and_idioms/idioms.rb', line 11 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
.all ⇒ Object
23 24 25 |
# File 'lib/words_and_idioms/idioms.rb', line 23 def self.all @@all end |