Class: MyShows::Episode

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

Overview

Provides such methods: title episode_number season_number short_name air_date sequence_number production_number image tvrage_link

Instance Attribute Summary collapse

Attributes inherited from Item

#id

Instance Method Summary collapse

Methods inherited from Item

#==, #method_missing

Constructor Details

#initialize(id, data, show) ⇒ Episode

Returns a new instance of Episode.



17
18
19
20
21
22
23
24
25
# File 'lib/myshows/episode.rb', line 17

def initialize(id, data, show)
  super(id, data)

  @show = show

  [:id, :show, :title, :season_number, :episode_number].each do |f|
    raise ArgumentError.new("#{f} could not be nil") if send(f).nil?
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MyShows::Item

Instance Attribute Details

#showObject (readonly)

Returns the value of attribute show.



15
16
17
# File 'lib/myshows/episode.rb', line 15

def show
  @show
end

Instance Method Details

#check!Object

Check episode as ‘watched’, requires authorization via Profile



33
34
35
# File 'lib/myshows/episode.rb', line 33

def check!
  @api.check_episode self
end

#to_sObject



27
28
29
# File 'lib/myshows/episode.rb', line 27

def to_s
  "#{show} - #{season_number}x#{episode_number} - #{title}"
end

#uncheck!Object

Check episode as ‘unwatched’, requires authorization via Profile



39
40
41
# File 'lib/myshows/episode.rb', line 39

def uncheck!
  @api.uncheck_episode self
end