Class: Plex::Part

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

Constant Summary collapse

ATTRIBUTES =
%w(id key duration file size)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Part

Returns a new instance of Part.

Parameters:

  • nokogiri (Nokogiri::XML::Element)

    element that represents this part



10
11
12
13
14
15
16
17
18
# File 'lib/plex-ruby/part.rb', line 10

def initialize(node)
  node.attributes.each do |method, val|
    define_singleton_method(Plex.underscore(method).to_sym) do
      val.value
    end
  end

  @streams  = node.search('Stream').map { |m| Plex::Stream.new(m) }
end

Instance Attribute Details

#streamsObject (readonly)

Returns the value of attribute streams.



6
7
8
# File 'lib/plex-ruby/part.rb', line 6

def streams
  @streams
end

Instance Method Details

#==(other) ⇒ Object



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

def ==(other)
  if other.is_a? Plex::Part
    id == other.id
  else
    super
  end
end