Class: Plex::Video

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

Constant Summary collapse

ATTRIBUTES =
%w(ratingKey key studio type title titleSort contentRating summary
rating viewCount year tagline thumb art duration
originallyAvailableAt updatedAt)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Video

Returns a new instance of Video.

Parameters:

  • nokogiri (Nokogiri::XML::Element)

    element that represents this Video



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/plex-ruby/video.rb', line 12

def initialize(node)
  @attribute_hash = {}
  node.attributes.each do |method, val|
    @attribute_hash[Plex.underscore(method)] = val.value
    define_singleton_method(Plex.underscore(method).to_sym) do
      val.value
    end
  end

  @medias     = node.search('Media').map    { |m| Plex::Media.new(m)    }
  @genres     = node.search('Genre').map    { |m| Plex::Genre.new(m)    }
  @writers    = node.search('Writer').map   { |m| Plex::Writer.new(m)   }
  @directors  = node.search('Director').map { |m| Plex::Director.new(m) }
  @roles      = node.search('Role').map     { |m| Plex::Role.new(m)     }
end

Instance Attribute Details

#attribute_hashObject (readonly)

Returns the value of attribute attribute_hash.



8
9
10
# File 'lib/plex-ruby/video.rb', line 8

def attribute_hash
  @attribute_hash
end

#directorsObject (readonly)

Returns the value of attribute directors.



8
9
10
# File 'lib/plex-ruby/video.rb', line 8

def directors
  @directors
end

#genresObject (readonly)

Returns the value of attribute genres.



8
9
10
# File 'lib/plex-ruby/video.rb', line 8

def genres
  @genres
end

#mediasObject (readonly)

Returns the value of attribute medias.



8
9
10
# File 'lib/plex-ruby/video.rb', line 8

def medias
  @medias
end

#rolesObject (readonly)

Returns the value of attribute roles.



8
9
10
# File 'lib/plex-ruby/video.rb', line 8

def roles
  @roles
end

#writersObject (readonly)

Returns the value of attribute writers.



8
9
10
# File 'lib/plex-ruby/video.rb', line 8

def writers
  @writers
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/plex-ruby/video.rb', line 29

def ==(other)
  if other.is_a? Video
    key == other.key
  else
    super
  end
end