Sha256: 514aea803a8abf615f79e4733e7d0a4fc821d31fe715892c3a7681af705ba67b

Contents?: true

Size: 1004 Bytes

Versions: 7

Compression:

Stored size: 1004 Bytes

Contents

module Fletcher
  module Model
    class Thinkgeek < Fletcher::Model::Base
      # A regular expression for determining if a url comes from a specific service/website
      def self.regexp
        /thinkgeek\.com/
      end
        
      # Parse data and look for object attributes to give to object    
      def parse(data)
        super(data)
        
        case doc
        when Nokogiri::HTML::Document
          # Get Name
          self.name = doc.xpath("//meta[@property='og:title']/@content").first_string

          # Get Description
          self.description = doc.xpath("//meta[@property='og:description']/@content").first_string
  
          # Get Price
          parse_price(doc.xpath("//form[@id='buy']/h3").first_string) rescue nil
          
          # Get Images
          self.images = [{:src => doc.xpath("//meta[@property='og:image']/@content").first_string}] 
          self.image = images.first
        end            
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fletcher-0.6.9 lib/fletcher/models/thinkgeek.rb
fletcher-0.6.8 lib/fletcher/models/thinkgeek.rb
fletcher-0.6.7 lib/fletcher/models/thinkgeek.rb
fletcher-0.6.6 lib/fletcher/models/thinkgeek.rb
fletcher-0.6.5 lib/fletcher/models/thinkgeek.rb
fletcher-0.6.4 lib/fletcher/models/thinkgeek.rb
fletcher-0.6.2 lib/fletcher/models/thinkgeek.rb