Class: AMarmita::Scrapper
- Inherits:
-
Object
- Object
- AMarmita::Scrapper
show all
- Defined in:
- lib/a_marmita/scrapper.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(css_parser) ⇒ Scrapper
Returns a new instance of Scrapper.
7
8
9
10
11
|
# File 'lib/a_marmita/scrapper.rb', line 7
def initialize(css_parser)
@attributes = { id: 0 }
@css_parser = css_parser
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5
6
7
|
# File 'lib/a_marmita/scrapper.rb', line 5
def attributes
@attributes
end
|
#css_parser ⇒ Object
Returns the value of attribute css_parser.
5
6
7
|
# File 'lib/a_marmita/scrapper.rb', line 5
def css_parser
@css_parser
end
|
Instance Method Details
#run(options = {}) ⇒ Object
27
28
29
|
# File 'lib/a_marmita/scrapper.rb', line 27
def run(options = {})
raise '#run must be implemented'
end
|
#scrap(options = {}) ⇒ Object
21
22
23
24
25
|
# File 'lib/a_marmita/scrapper.rb', line 21
def scrap(options = {})
run(options)
valid? ? @attributes : nil
end
|
#to_hash ⇒ Object
17
18
19
|
# File 'lib/a_marmita/scrapper.rb', line 17
def to_hash
@attributes
end
|
#valid? ⇒ Boolean
13
14
15
|
# File 'lib/a_marmita/scrapper.rb', line 13
def valid?
@attributes[:id] > 0
end
|