Class: MyEpisodes::Episode
- Inherits:
-
Object
- Object
- MyEpisodes::Episode
- Defined in:
- lib/my_episodes/episode.rb
Instance Attribute Summary collapse
-
#air_date ⇒ Object
readonly
Returns the value of attribute air_date.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#show_name ⇒ Object
readonly
Returns the value of attribute show_name.
Instance Method Summary collapse
- #acquired? ⇒ Boolean
- #create(attrs) ⇒ Object
-
#initialize(season) ⇒ Episode
constructor
A new instance of Episode.
- #season ⇒ Object
- #watched? ⇒ Boolean
Constructor Details
#initialize(season) ⇒ Episode
Returns a new instance of Episode.
7 8 9 |
# File 'lib/my_episodes/episode.rb', line 7 def initialize(season) @season = season end |
Instance Attribute Details
#air_date ⇒ Object (readonly)
Returns the value of attribute air_date.
5 6 7 |
# File 'lib/my_episodes/episode.rb', line 5 def air_date @air_date end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/my_episodes/episode.rb', line 5 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/my_episodes/episode.rb', line 5 def number @number end |
#show_name ⇒ Object (readonly)
Returns the value of attribute show_name.
5 6 7 |
# File 'lib/my_episodes/episode.rb', line 5 def show_name @show_name end |
Instance Method Details
#acquired? ⇒ Boolean
26 27 28 |
# File 'lib/my_episodes/episode.rb', line 26 def acquired? !!@acquired end |
#create(attrs) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/my_episodes/episode.rb', line 11 def create(attrs) attrs = sanitize(attrs) @air_date = text(attrs[AIR_DATE_FIELD]) @show_name = text(attrs[SHOW_NAME_FIELD]) @number = text(attrs[NUMBER_FIELD]) @name = text(attrs[NAME_FIELD]) @acquired = checked?(attrs[ACQUIRED_FIELD]) @watched = checked?(attrs[WATCHED_FIELD]) self end |
#season ⇒ Object
22 23 24 |
# File 'lib/my_episodes/episode.rb', line 22 def season @season.freeze end |
#watched? ⇒ Boolean
30 31 32 |
# File 'lib/my_episodes/episode.rb', line 30 def watched? !!@watched end |