Class: WonderScrape::Writers::Hash
- Inherits:
-
Object
- Object
- WonderScrape::Writers::Hash
- Defined in:
- lib/wonder_scrape/writers/hash.rb
Constant Summary collapse
- NAME =
'hash'
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize ⇒ Hash
constructor
A new instance of Hash.
- #output_results ⇒ Object
- #write(entry) ⇒ Object
Constructor Details
#initialize ⇒ Hash
Returns a new instance of Hash.
9 10 11 |
# File 'lib/wonder_scrape/writers/hash.rb', line 9 def initialize @results = [] end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
13 14 15 |
# File 'lib/wonder_scrape/writers/hash.rb', line 13 def results @results end |
Instance Method Details
#output_results ⇒ Object
19 20 21 |
# File 'lib/wonder_scrape/writers/hash.rb', line 19 def output_results puts JSON.pretty_generate(@results) end |
#write(entry) ⇒ Object
15 16 17 |
# File 'lib/wonder_scrape/writers/hash.rb', line 15 def write(entry) @results << entry end |