Class: Plex::Show
- Inherits:
-
Object
- Object
- Plex::Show
- Defined in:
- lib/plex-ruby/show.rb
Constant Summary collapse
- ATTRIBUTES =
%w(ratingKey guid studio type title contentRating summary index rating year thumb art 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.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#first_episode ⇒ Episode
Selects the first episode of this show that is on the Plex Server.
-
#first_season ⇒ Season
Selects the first season of this show that is on the Plex Server Does not select season 0.
-
#initialize(section, key) ⇒ Show
constructor
A new instance of Show.
- #inspect ⇒ Object
-
#last_episode ⇒ Episode
Selects the last episode of this show that is on the Plex Server.
-
#last_season ⇒ Season
Selects the last season of this show that is on the Plex Server.
-
#season(number) ⇒ Season
Select a particular season.
-
#seasons ⇒ Array
The list of seasons in the library that belong to this Show.
-
#special_season ⇒ Season
Helper method for selecting the special Season of this show Season 0 is where Plex stores episodes that are not part of a regular season.
- #url ⇒ Object
Constructor Details
#initialize(section, key) ⇒ Show
Returns a new instance of Show.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/plex-ruby/show.rb', line 12 def initialize(section, key) @section = section @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::Show##{Plex.underscore(method+'!')} IS DEPRECATED! Use Plex::Show##{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/show.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/show.rb', line 8 def key @key end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
8 9 10 |
# File 'lib/plex-ruby/show.rb', line 8 def section @section end |
Instance Method Details
#==(other) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/plex-ruby/show.rb', line 92 def ==(other) #:nodoc: if other.is_a? Plex::Show key == other.key else super end end |
#first_episode ⇒ Episode
Selects the first episode of this show that is on the Plex Server
74 75 76 |
# File 'lib/plex-ruby/show.rb', line 74 def first_episode first_season.first_episode end |
#first_season ⇒ Season
Selects the first season of this show that is on the Plex Server Does not select season 0
59 60 61 |
# File 'lib/plex-ruby/show.rb', line 59 def first_season seasons.inject { |a, b| a.index.to_i < b.index.to_i && a.index.to_i > 0 ? a : b } end |
#inspect ⇒ Object
101 102 103 |
# File 'lib/plex-ruby/show.rb', line 101 def inspect #:nodoc: "#<Plex::Show: key=\"#{key}\" title=\"#{title}\">" end |
#last_episode ⇒ Episode
Selects the last episode of this show that is on the Plex Server
82 83 84 |
# File 'lib/plex-ruby/show.rb', line 82 def last_episode last_season.last_episode end |
#last_season ⇒ Season
Selects the last season of this show that is on the Plex Server
66 67 68 |
# File 'lib/plex-ruby/show.rb', line 66 def last_season seasons.max_by { |s| s.index.to_i } end |
#season(number) ⇒ Season
Select a particular season
42 43 44 |
# File 'lib/plex-ruby/show.rb', line 42 def season(number) seasons.detect { |sea| sea.index.to_i == number.to_i } end |
#seasons ⇒ Array
The list of seasons in the library that belong to this Show
34 35 36 |
# File 'lib/plex-ruby/show.rb', line 34 def seasons @seasons ||= search_children children end |
#special_season ⇒ Season
Helper method for selecting the special Season of this show Season 0 is where Plex stores episodes that are not part of a regular season. i.e. Christmas Specials
51 52 53 |
# File 'lib/plex-ruby/show.rb', line 51 def special_season season(0) end |
#url ⇒ Object
87 88 89 |
# File 'lib/plex-ruby/show.rb', line 87 def url #:nodoc: section.url end |