Class: Fletcher::Model::Etsy

Inherits:
Base
  • Object
show all
Defined in:
lib/fletcher/models/etsy.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#parse_price

Class Method Details

.regexpObject

A regular expression for determining if a url comes from a specific service/website



5
6
7
# File 'lib/fletcher/models/etsy.rb', line 5

def self.regexp
  /etsy\.com/
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
# File 'lib/fletcher/models/etsy.rb', line 10

def parse(data)
  super(data)
  
  case doc
  when Nokogiri::HTML::Document
    # Get Name
    self.name = doc.xpath("//span[@itemprop='name']").first_string

    # Get Description
    self.description = doc.xpath("//div[@id='description-text']").first_string

    # Get Price
    parse_price(doc.xpath("//meta[@itemprop='price']/@content").first_string)
                    
    # Get Images
    self.images = doc.xpath("//div[@id='image-main']//img").attribute_array 
    self.image = images.first
  end            
end