Class: Plex::Season
- Inherits:
-
Object
- Object
- Plex::Season
- Defined in:
- lib/plex-ruby/season.rb
Overview
Found at /library/metadata/:key
Constant Summary collapse
- ATTRIBUTES =
%w(ratingKey guid type title summary index thumb leafCount viewedLeafCount addedAt updatedAt)
Instance Attribute Summary collapse
-
#attribute_hash ⇒ Object
readonly
Returns the value of attribute attribute_hash.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#show ⇒ Object
readonly
Returns the value of attribute show.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#episode(number) ⇒ Episode
Select a particular episode.
-
#episodes ⇒ Array
Returns the list of episodes in the library that are a part of this Season.
-
#first_episode ⇒ Episode
Selects the first episode of this season that is on the Plex Server.
-
#initialize(show, key) ⇒ Season
constructor
A new instance of Season.
- #inspect ⇒ Object
-
#last_episode ⇒ Episode
Selects the last episode of this season that is on the Plex Server.
- #url ⇒ Object
Constructor Details
#initialize(show, key) ⇒ Season
Returns a new instance of Season.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/plex-ruby/season.rb', line 12 def initialize(show, key) @show = show @key = key @attribute_hash = {} directory.attributes.each do |method, val| @attribute_hash[Plex.underscore(method)] = val.value define_singleton_method(Plex.underscore(method).to_sym) do val.value end define_singleton_method(Plex.underscore(method+'!').to_sym) do puts "Plex::Season##{Plex.underscore(method+'!')} IS DEPRECATED! Use Plex::Season##{Plex.underscore(method)} instead." self.send(Plex.underscore(method)) end end @attribute_hash.merge({'key' => @key}) end |
Instance Attribute Details
#attribute_hash ⇒ Object (readonly)
Returns the value of attribute attribute_hash.
8 9 10 |
# File 'lib/plex-ruby/season.rb', line 8 def attribute_hash @attribute_hash end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/plex-ruby/season.rb', line 8 def key @key end |
#show ⇒ Object (readonly)
Returns the value of attribute show.
8 9 10 |
# File 'lib/plex-ruby/season.rb', line 8 def show @show end |
Instance Method Details
#==(other) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/plex-ruby/season.rb', line 66 def ==(other) #:nodoc: if other.is_a? Plex::Season key == other.key else super end end |
#episode(number) ⇒ Episode
Select a particular episode
42 43 44 |
# File 'lib/plex-ruby/season.rb', line 42 def episode(number) episodes.detect { |epi| epi.index.to_i == number.to_i } end |
#episodes ⇒ Array
Returns the list of episodes in the library that are a part of this Season
34 35 36 |
# File 'lib/plex-ruby/season.rb', line 34 def episodes @episodes ||= episodes_from_video(children) end |
#first_episode ⇒ Episode
Selects the first episode of this season that is on the Plex Server
49 50 51 |
# File 'lib/plex-ruby/season.rb', line 49 def first_episode episodes.min_by { |e| e.index.to_i } end |
#inspect ⇒ Object
75 76 77 |
# File 'lib/plex-ruby/season.rb', line 75 def inspect #:nodoc: "#<Plex::Season: key=\"#{key}\" title=\"#{title}\" index=\"#{index}\" show=\"#{show.title}\">" end |
#last_episode ⇒ Episode
Selects the last episode of this season that is on the Plex Server
56 57 58 |
# File 'lib/plex-ruby/season.rb', line 56 def last_episode episodes.max_by { |e| e.index.to_i } end |
#url ⇒ Object
61 62 63 |
# File 'lib/plex-ruby/season.rb', line 61 def url #:nodoc: show.url end |