Class: Drom::Search
Instance Attribute Summary collapse
-
#listings ⇒ Object
readonly
Returns the value of attribute listings.
Instance Method Summary collapse
- #<<(listing) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Search
constructor
A new instance of Search.
- #to_csv ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Search
Returns a new instance of Search.
6 7 8 9 10 11 12 |
# File 'lib/drom/search.rb', line 6 def initialize( = {}, &block) @start_page = start_page() @listings = [] @next_page = nil @progress_type = [:status] || :none start(@progress_type, &block) if () end |
Instance Attribute Details
#listings ⇒ Object (readonly)
Returns the value of attribute listings.
4 5 6 |
# File 'lib/drom/search.rb', line 4 def listings @listings end |
Instance Method Details
#<<(listing) ⇒ Object
14 15 16 |
# File 'lib/drom/search.rb', line 14 def <<(listing) @listings << listing end |
#each(&block) ⇒ Object
18 19 20 |
# File 'lib/drom/search.rb', line 18 def each(&block) @listings.each(&block) end |
#to_csv ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/drom/search.rb', line 22 def to_csv csv = CSV.generate do |csv| self.listings.uniq.each do |l| csv << [l["Ссылка"], l.map {|k,v| "#{k}: #{v}"}.join("\r\n")] end end print "TOTAL #{@listings.size}\n" File.write("listings.csv", csv) end |