Class: Scrobbler::Playlist

Inherits:
BaseXmlInfo show all
Includes:
ImageObjectFuncs, StreamableObjectFuncs
Defined in:
lib/scrobbler/playlist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StreamableObjectFuncs

#check_streamable_node, #maybe_streamable_attribute

Methods included from ImageObjectFuncs

#check_image_node, #image

Methods inherited from Base

add_cache, api_key=, #call, #call_pageable, fetch_http, get, load_from_cache, #populate_data, post_request, #request, request, sanitize, save_to_cache, secret=, validate_response_document

Constructor Details

#initialize(data = {}) ⇒ Playlist

Returns a new instance of Playlist

Raises:

  • (ArgumentError)


26
27
28
29
30
# File 'lib/scrobbler/playlist.rb', line 26

def initialize(data={})
  raise ArgumentError unless data.kind_of?(Hash)
  super(data)
  raise ArgumentError, "Url is required" if @url.empty?
end

Instance Attribute Details

#creatorObject (readonly)

Returns the value of attribute creator



11
12
13
# File 'lib/scrobbler/playlist.rb', line 11

def creator
  @creator
end

#dateObject (readonly)

Returns the value of attribute date



11
12
13
# File 'lib/scrobbler/playlist.rb', line 11

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description



12
13
14
# File 'lib/scrobbler/playlist.rb', line 12

def description
  @description
end

#durationObject (readonly)

Returns the value of attribute duration



12
13
14
# File 'lib/scrobbler/playlist.rb', line 12

def duration
  @duration
end

#idObject (readonly)

Returns the value of attribute id



11
12
13
# File 'lib/scrobbler/playlist.rb', line 11

def id
  @id
end

#sizeObject (readonly)

Returns the value of attribute size



12
13
14
# File 'lib/scrobbler/playlist.rb', line 12

def size
  @size
end

#streamableObject (readonly)

Returns the value of attribute streamable



12
13
14
# File 'lib/scrobbler/playlist.rb', line 12

def streamable
  @streamable
end

#titleObject (readonly)

Returns the value of attribute title



11
12
13
# File 'lib/scrobbler/playlist.rb', line 11

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url



11
12
13
# File 'lib/scrobbler/playlist.rb', line 11

def url
  @url
end

Class Method Details

.createObject

Raises:

  • (NotImplementedError)


21
22
23
24
# File 'lib/scrobbler/playlist.rb', line 21

def self.create
  # This function require authentication, but SimpleAuth is not yet 2.0
  raise NotImplementedError
end

.new_from_libxml(xml) ⇒ Object

Deprecated.

Alias for Playlist.new(:xml => xml)



17
18
19
# File 'lib/scrobbler/playlist.rb', line 17

def self.new_from_libxml(xml)
  Playlist.new(:xml => xml)
end

Instance Method Details

#add_trackObject

Raises:

  • (NotImplementedError)


70
71
72
73
# File 'lib/scrobbler/playlist.rb', line 70

def add_track
  # This function require authentication, but SimpleAuth is not yet 2.0
  raise NotImplementedError
end

#fetchObject

Raises:

  • (NotImplementedError)


75
76
77
78
# File 'lib/scrobbler/playlist.rb', line 75

def fetch
  # This function require authentication, but SimpleAuth is not yet 2.0
  raise NotImplementedError
end

#load_from_xml(node) ⇒ nil

Load the data for this object out of a XML-Node



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/scrobbler/playlist.rb', line 36

def load_from_xml(node)
  # Get all information from the root's children nodes
  node.children.each do |child|
    case child.name.to_s
      when 'id'
        @id = child.content.to_i
      when 'title'
        @title = child.content
      when 'image'
        check_image_node(child)
      when 'date'
        @date = Time.parse(child.content)
      when 'streamable'
        check_streamable_node(child)
      when 'size'
        @size = child.content.to_i
      when 'description'
        @description = child.content
      when 'duration'
        @duration = child.content.to_i
      when 'creator'
        @creator = child.content
      when 'url'
        @url = child.content
      when 'text'
        # ignore, these are only blanks
      when '#text'
        # libxml-jruby version of blanks
      else
        raise NotImplementedError, "Field '#{child.name}' not known (#{child.content})"
    end #^ case
  end #^ do |child|
end