Class: TopTv::Heading

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, shows) ⇒ Heading

Returns a new instance of Heading.



13
14
15
16
17
# File 'lib/top_tv/heading.rb', line 13

def initialize(name, shows)
  @name = name
  @shows = shows
  @@all << self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/top_tv/heading.rb', line 2

def name
  @name
end

#showsObject

Returns the value of attribute shows.



2
3
4
# File 'lib/top_tv/heading.rb', line 2

def shows
  @shows
end

Class Method Details

.allObject



19
20
21
# File 'lib/top_tv/heading.rb', line 19

def self.all
  @@all
end

.new_from_home_page(heading) ⇒ Object



6
7
8
9
10
11
# File 'lib/top_tv/heading.rb', line 6

def self.new_from_home_page(heading)
  self.new(
    heading.css("h2").text.gsub(" on RT", ""),
    heading.css("tr td.middle_col a").collect {|show| show.text.gsub(" View All ", "").gsub(",", "")}.join(",").split(",")
  )
end