Class: AmazonOrder::Parsers::Product
- Inherits:
-
Base
- Object
- Base
- AmazonOrder::Parsers::Product
show all
- Defined in:
- lib/amazon_order/parsers/product.rb
Constant Summary
collapse
- ATTRIBUTES =
%w[
title
path
content
image_url
]
Instance Attribute Summary
Attributes inherited from Base
#fetched_at
Instance Method Summary
collapse
Methods inherited from Base
#get_original_image_url, #initialize, #inspect, #parse_date, #to_hash, #values
Instance Method Details
#content ⇒ Object
19
20
21
|
# File 'lib/amazon_order/parsers/product.rb', line 19
def content
@_content ||= @node.css('.a-col-right .a-row')[1..-1].map(&:text).join.gsub(/\s+/, ' ').strip
end
|
#image_url ⇒ Object
23
24
25
26
27
28
|
# File 'lib/amazon_order/parsers/product.rb', line 23
def image_url
@_image_url ||= begin
img = @node.css('.a-col-left img')[0]
get_original_image_url(img.attr('data-a-hires').presence || img.attr('src'))
end
end
|
#path ⇒ Object
15
16
17
|
# File 'lib/amazon_order/parsers/product.rb', line 15
def path
@_path ||= @node.css('.a-col-right .a-row a')[0].attr('href') rescue nil
end
|
#title ⇒ Object
11
12
13
|
# File 'lib/amazon_order/parsers/product.rb', line 11
def title
@_title ||= @node.css('.a-col-right .a-row')[0].text.strip
end
|