Class: DansDeals::Deals

Inherits:
Object
  • Object
show all
Defined in:
lib/dansdeals/deals.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



2
3
4
# File 'lib/dansdeals/deals.rb', line 2

def body
  @body
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/dansdeals/deals.rb', line 2

def title
  @title
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/dansdeals/deals.rb', line 2

def url
  @url
end

Class Method Details

.latestObject



3
4
5
# File 'lib/dansdeals/deals.rb', line 3

def self.latest
  self.scrape_deals
end

.scrape_dealsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dansdeals/deals.rb', line 7

def self.scrape_deals

  doc = Nokogiri::HTML(open("http://www.dansdeals.com"))

  doc.css(".td_module_10").collect do |post|
    deal = self.new
    deal.title = post.css("h3.entry-title").text
    deal.body = post.css(".td-excerpt").first.inner_text.strip
    deal.url = post.css("h3 a").attribute("href").value

    deal
  end
end