Class: DataMapper::YS::Scraper::Base
- Inherits:
-
Object
- Object
- DataMapper::YS::Scraper::Base
- Includes:
- CachedAccessor
- Defined in:
- lib/dm-ys/scraper.rb
Overview
Base Scraper
Instance Method Summary collapse
- #base_uri ⇒ Object
- #count ⇒ Object
-
#initialize(model, *args) ⇒ Base
constructor
A new instance of Base.
- #register_properties! ⇒ Object
- #uri ⇒ Object
Methods included from CachedAccessor
Constructor Details
#initialize(model, *args) ⇒ Base
Returns a new instance of Base.
54 55 56 57 58 |
# File 'lib/dm-ys/scraper.rb', line 54 def initialize(model, *args) raise ArgumentError, "missing model" unless model raise ArgumentError, "missing uri" unless model.uri @model = model end |
Instance Method Details
#base_uri ⇒ Object
71 72 73 |
# File 'lib/dm-ys/scraper.rb', line 71 def base_uri URI.parse(uri.split('?').first) end |
#count ⇒ Object
63 64 65 |
# File 'lib/dm-ys/scraper.rb', line 63 def count records.size end |
#register_properties! ⇒ Object
75 76 77 78 79 80 |
# File 'lib/dm-ys/scraper.rb', line 75 def register_properties! names.each do |name| type = String # TODO @model.property name.intern, type end end |
#uri ⇒ Object
67 68 69 |
# File 'lib/dm-ys/scraper.rb', line 67 def uri @uri || @model.uri.to_s.chomp('*') end |