Class: WhatsOn::Show

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#airingObject

Returns the value of attribute airing.



2
3
4
# File 'lib/whats_on/show.rb', line 2

def airing
  @airing
end

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/whats_on/show.rb', line 2

def description
  @description
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/whats_on/show.rb', line 2

def name
  @name
end

Class Method Details

.allObject



5
6
7
# File 'lib/whats_on/show.rb', line 5

def self.all
  self.scrape_shows
end

.scrape_showsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/whats_on/show.rb', line 9

def self.scrape_shows

shows_array= []

  doc = Nokogiri::HTML(open("http://www.tvguide.com/trending-tonight/"))

  doc.css(".listings-program").each do |item|
    production = {
      :name => item.at_css(".listings-program-link").text,
      :airing => item.at_css(".listings-program-airing-info").text,
      :description => item.at_css(".listings-program-description").text
    }
      shows_array<<production
  end
  shows_array
end