Class: Fletcher::Model::Googleshopping
- Defined in:
- lib/fletcher/models/googleshopping.rb
Class Method Summary collapse
-
.regexp ⇒ Object
A regular expression for determining if a url comes from a specific service/website.
Instance Method Summary collapse
-
#parse(data) ⇒ Object
Parse data and look for object attributes to give to object.
Methods inherited from Base
Class Method Details
.regexp ⇒ Object
A regular expression for determining if a url comes from a specific service/website
5 6 7 |
# File 'lib/fletcher/models/googleshopping.rb', line 5 def self.regexp /google\.com/ end |
Instance Method Details
#parse(data) ⇒ Object
Parse data and look for object attributes to give to object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 |