Class: MyEpisodes::Episode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dateObject (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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#show_nameObject (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

Returns:

  • (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

#seasonObject



22
23
24
# File 'lib/my_episodes/episode.rb', line 22

def season
  @season.freeze
end

#watched?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/my_episodes/episode.rb', line 30

def watched?
  !!@watched
end