Class: Threecast::News
- Inherits:
-
Object
- Object
- Threecast::News
- Defined in:
- lib/threecast/news.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#network ⇒ Object
Returns the value of attribute network.
-
#story ⇒ Object
Returns the value of attribute story.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .news_creator(doc) ⇒ Object
- .scrape_cnn ⇒ Object
- .scrape_deals ⇒ Object
- .scrape_foxnews ⇒ Object
- .scrape_msnbc ⇒ Object
- .today ⇒ Object
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/threecast/news.rb', line 2 def date @date end |
#network ⇒ Object
Returns the value of attribute network.
2 3 4 |
# File 'lib/threecast/news.rb', line 2 def network @network end |
#story ⇒ Object
Returns the value of attribute story.
2 3 4 |
# File 'lib/threecast/news.rb', line 2 def story @story end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/threecast/news.rb', line 2 def url @url end |
Class Method Details
.news_creator(doc) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/threecast/news.rb', line 33 def self.news_creator(doc) news = self.new news.story = doc.search(".js-tweet-text-container p").first.text news.url = doc.search(".js-tweet-text-container p a").attr("href").value news.network = doc.search(".account-group .fullname").first.text news.date = doc.search(".stream-item-header .time a").attr("title").value news end |
.scrape_cnn ⇒ Object
18 19 20 21 |
# File 'lib/threecast/news.rb', line 18 def self.scrape_cnn doc = Nokogiri::HTML(open("https://twitter.com/cnn")) self.news_creator(doc) end |
.scrape_deals ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/threecast/news.rb', line 8 def self.scrape_deals news = [] news << self.scrape_cnn news << self.scrape_msnbc news << self.scrape_foxnews news end |
.scrape_foxnews ⇒ Object
28 29 30 31 |
# File 'lib/threecast/news.rb', line 28 def self.scrape_foxnews doc = Nokogiri::HTML(open("https://twitter.com/foxnews")) self.news_creator(doc) end |
.scrape_msnbc ⇒ Object
23 24 25 26 |
# File 'lib/threecast/news.rb', line 23 def self.scrape_msnbc doc = Nokogiri::HTML(open("https://twitter.com/msnbc")) self.news_creator(doc) end |
.today ⇒ Object
4 5 6 |
# File 'lib/threecast/news.rb', line 4 def self.today self.scrape_deals end |