Class: OzonParser::Pages::Base
- Inherits:
-
OzonParser::Page
- Object
- OzonParser::Page
- OzonParser::Pages::Base
- Defined in:
- lib/ozon_parser/pages/base.rb
Direct Known Subclasses
Constant Summary
Constants inherited from OzonParser::Page
OzonParser::Page::BASE_OZON_URL
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from OzonParser::Page
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Base
constructor
A new instance of Base.
-
#parse_url(id) ⇒ String
This method need to point url source of page.
Methods inherited from OzonParser::Page
#agent, #clean_up, field, #file, #format_date, #json, #root, #source, #untypofy
Constructor Details
#initialize(args = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ozon_parser/pages/base.rb', line 13 def initialize(args = {}) @source = args.delete(:source) @url= args.delete(:url) @id= args.delete(:id) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end return super(source: @source) if @source return super(url: @url) if @url raise InitError if @id.nil? @url = parse_url(@id) super(url: @url) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/ozon_parser/pages/base.rb', line 4 def id @id end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/ozon_parser/pages/base.rb', line 4 def url @url end |
Instance Method Details
#parse_url(id) ⇒ String
This method need to point url source of page
9 10 11 |
# File 'lib/ozon_parser/pages/base.rb', line 9 def parse_url(id) BASE_OZON_URL + "/context/detail/id/#{id}/" end |