Top Level Namespace

Defined Under Namespace

Modules: Ioffer Classes: IOfferPage, IOfferSearch, IOfferSearchResults

Instance Method Summary collapse

Instance Method Details

#page_active?(html) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/ioffer/page.rb', line 30

def page_active?(html)
  doc = Nokogiri::HTML(html)
  !!/You are being/.match(html).nil? && !!doc.at("//div[@id='solr-search-results']").nil?
end

#parse_description(element) ⇒ Object



26
27
28
# File 'lib/ioffer/page.rb', line 26

def parse_description(element)
  Sanitize.clean(element).strip
end

#parse_item_id(element) ⇒ Object

def make_price(element)

/\$([\d,]+\.?[\d]{2})/.match(element)[1]

end



17
18
19
# File 'lib/ioffer/page.rb', line 17

def parse_item_id(element)
  /Item #([\d]*)/.match(element.text)[1]
end

#parse_posted_date(element) ⇒ Object



21
22
23
24
# File 'lib/ioffer/page.rb', line 21

def parse_posted_date(element)
  date = /Listed: ([\d]{2,}-[\d]{2,}-[\d]{2,})/.match(element.text)[1]
  Date.strptime(date, '%m-%d-%y')
end

#parse_title(title) ⇒ Object



12
13
14
# File 'lib/ioffer/search.rb', line 12

def parse_title(title)
  title.inner_text.gsub(/[\s]{2,}/, " ")
end