Sha256: d0cf6faa32d21b2daf4d0f448284cbe4467dc639e7d7df2b52f5744e7108b449

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

module AmazonOrder
  module Parsers
    class Product < Base
      ATTRIBUTES = %w[
                     title
                     path
                     content
                     image_url
                   ]

      def title
        @_title ||= @node.css('.a-col-right .a-row')[0].text.strip
      end

      def path
        @_path ||= @node.css('.a-col-right .a-row a')[0].attr('href') rescue nil
      end

      def content
        @_content ||= @node.css('.a-col-right .a-row')[1..-1].map(&:text).join.gsub(/\s+/, ' ').strip
      end

      def image_url
        @_image_url ||= get_original_image_url(@node.css('.a-col-left img')[0].attr('src'))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amazon_order-0.1.1 lib/amazon_order/parsers/product.rb
amazon_order-0.1.0 lib/amazon_order/parsers/product.rb