Class: Plex::Episode

Inherits:
Object
  • Object
show all
Defined in:
lib/plex-ruby/episode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(season, key) ⇒ Episode

Returns a new instance of Episode.

Parameters:

  • season (Season)

    this episode belongs to

  • key (String)

    that we can use to later grab this Episode


8
9
10
11
# File 'lib/plex-ruby/episode.rb', line 8

def initialize(season, key)
  @season = season
  @key = key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Delegates all method calls to the video object that represents this episode, if that video object responds to the method.


20
21
22
23
24
25
26
# File 'lib/plex-ruby/episode.rb', line 20

def method_missing(method, *args, &block)
  if video.respond_to? method
    video.send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key


4
5
6
# File 'lib/plex-ruby/episode.rb', line 4

def key
  @key
end

#seasonObject (readonly)

Returns the value of attribute season


4
5
6
# File 'lib/plex-ruby/episode.rb', line 4

def season
  @season
end

Instance Method Details

#==(other) ⇒ Object


42
43
44
45
46
47
48
# File 'lib/plex-ruby/episode.rb', line 42

def ==(other) #:nodoc:
  if other.is_a? Plex::Episode
    key == other.key
  else
    super
  end
end

#attribute_hashObject

Returns the attribute hash that represents this Episode


14
15
16
# File 'lib/plex-ruby/episode.rb', line 14

def attribute_hash
  video.attribute_hash.merge({'key' => key})
end

#inspectObject


51
52
53
# File 'lib/plex-ruby/episode.rb', line 51

def inspect #:nodoc:
  "#<Plex::Episode key=\"#{key}\" title=\"#{title}\" index=\"#{index}\" season=\"#{season.index}\" show=\"#{season.show.title}\">"
end

#methodsObject


32
33
34
# File 'lib/plex-ruby/episode.rb', line 32

def methods
  (super + video.methods).uniq
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/plex-ruby/episode.rb', line 28

def respond_to?(method)
  super || video.respond_to?(method)
end

#urlObject


37
38
39
# File 'lib/plex-ruby/episode.rb', line 37

def url #:nodoc:
  season.url
end