Class: ExtraLoop::ScraperBase
- Inherits:
-
Object
- Object
- ExtraLoop::ScraperBase
- Defined in:
- lib/extraloop/scraper_base.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
2 3 4 |
# File 'lib/extraloop/scraper_base.rb', line 2 def session @session end |
Instance Method Details
#set_storage(model, title = nil, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/extraloop/scraper_base.rb', line 5 def set_storage(model, title=nil, ={}) collection_name = "#{Time.now.to_i} #{model.to_s} Dataset" title ||= collection_name @model = model_klass = model.respond_to?(:new) && model || ExtraLoop::Storage::DatasetFactory.new(model.to_sym, @extractor_args.map(&:first)).get_class log_session! title log_session! title on :data do |results| results = results.map { |result| @scraper.send(:instanciate_model, result) } block_given? && yield(results) || results.each { |result| result.save if result.respond_to?(:save) } end end |