Class: DataMapper::YunkerStar::Scraper::Base

Inherits:
Object
  • Object
show all
Includes:
CachedAccessor
Defined in:
lib/dm-ys/scraper.rb

Overview

Base Scraper

Direct Known Subclasses

Composite, Page

Instance Method Summary collapse

Methods included from CachedAccessor

included

Constructor Details

#initialize(model, *args) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


53
54
55
56
57
# File 'lib/dm-ys/scraper.rb', line 53

def initialize(model, *args)
  raise ArgumentError, "missing model" unless model
  raise ArgumentError, "missing uri"   unless model.uri
  @model = model
end

Instance Method Details

#register_properties!Object



66
67
68
69
70
71
# File 'lib/dm-ys/scraper.rb', line 66

def register_properties!
  names.each do |name|
    type = String         # TODO
    @model.property name.intern, type
  end
end

#uriObject



62
63
64
# File 'lib/dm-ys/scraper.rb', line 62

def uri
  @uri || @model.uri.to_s.chomp('*')
end