Class: Skyscraper::Base
- Inherits:
-
Object
- Object
- Skyscraper::Base
- Defined in:
- lib/skyscraper/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#pages_object ⇒ Object
Returns the value of attribute pages_object.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #after_all(&block) ⇒ Object
- #after_each(&block) ⇒ Object
- #continue ⇒ Object
- #fetch ⇒ Object
- #field(name, selector, attribute = nil, &block) ⇒ Object
-
#initialize(config = nil) ⇒ Base
constructor
A new instance of Base.
- #pages(options = {}, &block) ⇒ Object
- #settings(options = {}) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 10 11 |
# File 'lib/skyscraper/base.rb', line 5 def initialize config = nil @config = (config || Skyscraper::Config.new(Skyscraper.defaults.dup)) @fields = [] = {} @pages_object = Pages.new @results = Results.new self end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/skyscraper/base.rb', line 3 def config @config end |
#fields ⇒ Object
Returns the value of attribute fields.
3 4 5 |
# File 'lib/skyscraper/base.rb', line 3 def fields @fields end |
#pages_object ⇒ Object
Returns the value of attribute pages_object.
3 4 5 |
# File 'lib/skyscraper/base.rb', line 3 def pages_object @pages_object end |
#results ⇒ Object
Returns the value of attribute results.
3 4 5 |
# File 'lib/skyscraper/base.rb', line 3 def results @results end |
Instance Method Details
#after_all(&block) ⇒ Object
26 27 28 |
# File 'lib/skyscraper/base.rb', line 26 def after_all &block @results.add_after_all &block end |
#after_each(&block) ⇒ Object
22 23 24 |
# File 'lib/skyscraper/base.rb', line 22 def after_each &block @results.add_after_each &block end |
#continue ⇒ Object
40 41 42 |
# File 'lib/skyscraper/base.rb', line 40 def continue @results.continue end |
#fetch ⇒ Object
36 37 38 |
# File 'lib/skyscraper/base.rb', line 36 def fetch @results.fetch end |
#field(name, selector, attribute = nil, &block) ⇒ Object
17 18 19 20 |
# File 'lib/skyscraper/base.rb', line 17 def field name, selector, attribute = nil, &block @fields.delete @fields.detect { |f| f.name == name } @fields << Field.new(name: name, selector: selector, callback: block) end |
#pages(options = {}, &block) ⇒ Object
13 14 15 |
# File 'lib/skyscraper/base.rb', line 13 def pages = {}, &block @pages_object.set , &block end |
#settings(options = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/skyscraper/base.rb', line 30 def settings = {} .each_pair do |key, val| @config.send "#{key}=", val end end |