Class: MyEpisodes::Shows

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/my_episodes/shows.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ Shows

Returns a new instance of Shows.



7
8
9
10
# File 'lib/my_episodes/shows.rb', line 7

def initialize(parser)
  @shows = []
  @parser = parser
end

Instance Method Details

#create(links) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/my_episodes/shows.rb', line 12

def create(links)
  links.each do |link|
    name = link.text
    page = link.click
    rows = @parser.parse(page)
    @shows << Show.new(name).create(rows)
  end

  self
end

#each(&block) ⇒ Object



23
24
25
# File 'lib/my_episodes/shows.rb', line 23

def each(&block)
  @shows.each(&block)
end