Class: DansDeals::Deals
- Inherits:
-
Object
- Object
- DansDeals::Deals
- Defined in:
- lib/dansdeals/deals.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
2 3 4 |
# File 'lib/dansdeals/deals.rb', line 2 def body @body end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/dansdeals/deals.rb', line 2 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/dansdeals/deals.rb', line 2 def url @url end |
Class Method Details
.latest ⇒ Object
3 4 5 |
# File 'lib/dansdeals/deals.rb', line 3 def self.latest self.scrape_deals end |
.scrape_deals ⇒ Object
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 |