Class: Plex::Section

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

Constant Summary collapse

GROUPS =
%w(all unwatched newest recentlyAdded recentlyViewed onDeck)
ATTRIBUTES =
%w(refreshing key type title art agent scanner language updatedAt)
CATEGORIES =
%w(collection firstCharacter genre year contentRating folder)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(library, node) ⇒ Section

Returns a new instance of Section.

Parameters:

  • library (Library)

    this Section belongs to

  • nokogiri (Nokogiri::XML::Element)

    element that represents this Section



16
17
18
19
20
21
# File 'lib/plex-ruby/section.rb', line 16

def initialize(library, node)
  @library = library
  ATTRIBUTES.each { |e|
    instance_variable_set("@#{Plex.underscore(e)}", node.attr(e))
  }
end

Instance Attribute Details

#libraryObject (readonly)

Returns the value of attribute library.



11
12
13
# File 'lib/plex-ruby/section.rb', line 11

def library
  @library
end

Instance Method Details

#==(other) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/plex-ruby/section.rb', line 90

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

#inspectObject



99
100
101
# File 'lib/plex-ruby/section.rb', line 99

def inspect #:nodoc:
  "#<Plex::Section: key=\"#{key}\" type=\"#{type}\" title=\"#{title}\">"
end

#keyObject



80
81
82
# File 'lib/plex-ruby/section.rb', line 80

def key #:nodoc:
  "/library/sections/#{@key}"
end

#methodArray

Returns a list of shows or movies that are in this Section.

all - all videos in this Section unwatched - videos unwatched in this Section newest - most recent videos in this Section recently_added - recently added videos in this Section recently_viewed - recently viewed videos in this Section on_deck - videos that are “on deck” in this Section

Returns:

  • (Array)

    list of Shows or Movies in that group



38
39
40
41
42
43
44
# File 'lib/plex-ruby/section.rb', line 38

GROUPS.each { |method|
  class_eval %(
    def #{Plex.underscore(method)}
      Plex::Parser.new( self, Nokogiri::XML(Plex.open(url+key+'/#{method}')) ).parse
    end
  )
}

#refresh(deep = false, force = false) ⇒ Object

NOT IMPLEMENTED



24
25
# File 'lib/plex-ruby/section.rb', line 24

def refresh(deep = false, force = false)
end

#urlObject



85
86
87
# File 'lib/plex-ruby/section.rb', line 85

def url #:nodoc:
  library.url
end