Sha256: fc3b35412d0553b471d0d3a8a3780b857f97224a740b6cee19d201fa04c5b526

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

module Fletcher
  module Item
    class Thinkgeek < Fletcher::Item::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)
        # Store raw document object 
        self.doc = 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 Images
          self.images = [{:url => doc.xpath("//meta[@property='og:image']/@content").first_string}] 
          self.image = images.first
        end            
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fletcher-0.2.0 lib/fletcher/item/thinkgeek.rb