Class: Plex::Media

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

Constant Summary collapse

ATTRIBUTES =
%w(id durration bitrate aspectRatio audioChannels
audioCodec videoCodec videoResolution container videoFrameRate)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Media

Returns a new instance of Media.

Parameters:

  • nokogiri (Nokogiri::XML::Element)

    element that represents this Media



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

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

  @parts = node.search("Part").map { |m| Plex::Part.new(m) }
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



7
8
9
# File 'lib/plex-ruby/media.rb', line 7

def parts
  @parts
end

Instance Method Details

#==(other) ⇒ Object



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

def ==(other)
  if other.is_a? Media
    id == other.id
  else
    super
  end
end