Class: Fletcher::Model::Gamecouk
- Defined in:
- lib/fletcher/models/gamecouk.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/gamecouk.rb', line 5 def self.regexp /game\.co\.uk/ 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 29 30 31 32 33 34 35 36 37 |
# File 'lib/fletcher/models/gamecouk.rb', line 10 def parse(data) super(data) case doc when Nokogiri::HTML::Document require 'date' # Get Name self.name = doc.xpath("//meta[@property='og:title']/@content").first_string # Get Description # OMITTED: This is tough to get because ebay item descriptions are custom html/content created by sellers self.description = doc.css('div#primary div#details.panel div.description').to_s self.release_date = doc.css('div#primary div#details.panel p.releaseDate').first_string self.release_date = Date.strptime(self.release_date.gsub('Released on ',''), '%d-%b-%Y') if self.release_date # Get Price raw_price = doc.css("ul#variants ul.mint li.price").first_string Money.default_currency = Money::Currency.new("GBP") parse_price(raw_price.gsub(/Only /, "")) if raw_price # Get Image self.images = [{:src => doc.xpath("//meta[@property='og:image']/@content").first_string}] self.image = images.first end end |