class Fletcher::Model::Playcom
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/playcom.rb, line 6 def self.regexp /play\.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/playcom.rb, line 11 def parse(data) super(data) case doc when Nokogiri::HTML::Document # Get Name self.name = doc.xpath("//h1[@itemprop='name']").first_string self.description = doc.css('div.line div.unit div.tabs section#Description').to_s # Get Price raw_price = doc.css('div.product-overview div.line span.price').first_string parse_price(raw_price.gsub(/\302\243/,'')) if raw_price # Get Image self.image = doc.css('a#main_product img')[0][:src].to_s unless doc.css('a#main_product img').nil? end end