Class: MyEpisodes::Show
- Inherits:
-
Object
- Object
- MyEpisodes::Show
- Defined in:
- lib/my_episodes/show.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #create(rows) ⇒ Object
-
#initialize(name) ⇒ Show
constructor
A new instance of Show.
- #seasons ⇒ Object
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
#name ⇒ Object (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 |
#seasons ⇒ Object
27 28 29 |
# File 'lib/my_episodes/show.rb', line 27 def seasons @seasons.freeze end |