Class: OzonParser::Pages::Base

Inherits:
OzonParser::Page show all
Defined in:
lib/ozon_parser/pages/base.rb

Direct Known Subclasses

Book

Constant Summary

Constants inherited from OzonParser::Page

OzonParser::Page::BASE_OZON_URL

Instance Attribute Summary collapse

Attributes inherited from OzonParser::Page

#result

Instance Method Summary collapse

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.

Raises:



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

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/ozon_parser/pages/base.rb', line 4

def id
  @id
end

#urlObject

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

Returns:

  • (String)

    url



9
10
11
# File 'lib/ozon_parser/pages/base.rb', line 9

def parse_url(id)
  BASE_OZON_URL + "/context/detail/id/#{id}/"
end