class Fletcher::Model::Googleshopping

Public Class Methods

regexp() click to toggle source

A regular expression for determining if a url comes from a specific service/website

# File lib/fletcher/models/googleshopping.rb, line 5
def self.regexp
  /google\.com/
end

Public Instance Methods

parse(data) click to toggle source

Parse data and look for object attributes to give to object

Calls superclass method Fletcher::Model::Base#parse
# File lib/fletcher/models/googleshopping.rb, line 10
def parse(data)
  super(data)
  case doc
  when Nokogiri::HTML::Document
    # Get Name
    name = doc.css('h1#product-name span.main-title').first_string
    self.name = name if name

    # Get Description
    self.description = doc.css("#product-description-full").first_string   

    # Get Price
    parse_price( doc.css('#summary-prices .price').first_string )
                    
    # Get Images
    self.images = doc.css('div#product-basic-info img').attribute_array
    self.image = images.first
  end            
end