Class: MyEpisodes::Show

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Show

Returns a new instance of Show.



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

def initialize(name)
  @name = name
  @seasons = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#create(rows) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/my_episodes/show.rb', line 12

def create(rows)
  season = nil
  rows.each do |row|
    if useless?(row)
      next
    elsif new_season?(row)
      @seasons << Season.new(self).create(row)
      season = @seasons.last
    else
      season << Episode.new(season).create(row.children)
    end
  end
  self
end

#seasonsObject



27
28
29
# File 'lib/my_episodes/show.rb', line 27

def seasons
  @seasons.freeze
end