class Jaleb::Model::Ebay
Public Class Methods
regexp()
click to toggle source
A regular expression for determining if a url comes from a specific service/website
# File lib/jaleb/models/ebay.rb, line 5 def self.regexp /ebay\.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
Jaleb::Model::Base#parse
# File lib/jaleb/models/ebay.rb, line 10 def parse(data) super(data) case doc when Nokogiri::HTML::Document # Get Name self.name = doc.xpath("//h1[@itemprop='name']").first_string # Get Description # OMITTED: This is tough to get because ebay item descriptions are custom html/content created by sellers # Get Price raw_price = doc.xpath("//span[@itemprop='price']").first_string parse_price(raw_price.gsub(/US/, "")) if raw_price # Get Image self.images = [{:src => doc.xpath("//span[@itemprop='image']/img").first_string}] self.image = images.first end end