Class: Threecast::News

Inherits:
Object
  • Object
show all
Defined in:
lib/threecast/news.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dateObject

Returns the value of attribute date.



2
3
4
# File 'lib/threecast/news.rb', line 2

def date
  @date
end

#networkObject

Returns the value of attribute network.



2
3
4
# File 'lib/threecast/news.rb', line 2

def network
  @network
end

#storyObject

Returns the value of attribute story.



2
3
4
# File 'lib/threecast/news.rb', line 2

def story
  @story
end

#urlObject

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_cnnObject



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_dealsObject



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_foxnewsObject



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_msnbcObject



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

.todayObject



4
5
6
# File 'lib/threecast/news.rb', line 4

def self.today
  self.scrape_deals
end