Class: Scrobbler::Tag
- Inherits:
- BaseXml show all
- Includes:
- StreamableObjectFuncs
- Defined in:
- lib/scrobbler/tag.rb
Instance Attribute Summary (collapse)
-
- (Object) count
readonly
Returns the value of attribute count.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) streamable
readonly
Returns the value of attribute streamable.
-
- (Object) url
readonly
Returns the value of attribute url.
Class Method Summary (collapse)
- + (Object) new_from_libxml(xml) deprecated Deprecated.
- + (Object) search
- + (Object) top_tags
Instance Method Summary (collapse)
-
- (Tag) initialize(data = {})
constructor
Create a new Scrobbler::Artist instance.
-
- (nil) load_from_xml(node)
Load the data for this object out of a XML-Node.
-
- (Object) similar
Search for tags similar to this one.
- - (Object) top_albums
-
- (Object) top_artists
^ load_from_xml.
- - (Object) top_tracks
- - (Object) weekly_artist_chart
- - (Object) weekly_chart_list
Methods included from StreamableObjectFuncs
#check_streamable_node, #maybe_streamable_attribute
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
- (Tag) initialize(data = {})
Create a new Scrobbler::Artist instance
21 22 23 24 25 |
# File 'lib/scrobbler/tag.rb', line 21 def initialize(data = {}) raise ArgumentError unless data.kind_of?(Hash) super(data) raise ArgumentError, "Name is required" if @name.nil? || @name.strip.empty? end |
Instance Attribute Details
- (Object) count (readonly)
Returns the value of attribute count
9 10 11 |
# File 'lib/scrobbler/tag.rb', line 9 def count @count end |
- (Object) name (readonly)
Returns the value of attribute name
9 10 11 |
# File 'lib/scrobbler/tag.rb', line 9 def name @name end |
- (Object) streamable (readonly)
Returns the value of attribute streamable
9 10 11 |
# File 'lib/scrobbler/tag.rb', line 9 def streamable @streamable end |
- (Object) url (readonly)
Returns the value of attribute url
9 10 11 |
# File 'lib/scrobbler/tag.rb', line 9 def url @url end |
Class Method Details
+ (Object) new_from_libxml(xml)
Alias for Artist.new(:xml => xml)
14 15 16 |
# File 'lib/scrobbler/tag.rb', line 14 def self.new_from_libxml(xml) Tag.new(:xml => xml) end |
+ (Object) search
69 70 71 72 |
# File 'lib/scrobbler/tag.rb', line 69 def self.search # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
+ (Object) top_tags
65 66 67 |
# File 'lib/scrobbler/tag.rb', line 65 def self. Base.get('tag.gettoptags', :toptags, Tag) end |
Instance Method Details
- (nil) load_from_xml(node)
Load the data for this object out of a XML-Node
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/scrobbler/tag.rb', line 31 def load_from_xml(node) # Get all information from the root's children nodes node.children.each do |child| case child.name when 'count' @count = child.content.to_i when 'url' @url = child.content when 'name' @name = child.content when 'streamable' check_streamable_node(child) 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 |
- (Object) similar
Search for tags similar to this one. Returns tags ranked by similarity, based on listening data.
77 78 79 |
# File 'lib/scrobbler/tag.rb', line 77 def similar call('tag.getsimilar', :similartags, Tag, {:tag => @name}) end |
- (Object) top_albums
57 58 59 |
# File 'lib/scrobbler/tag.rb', line 57 def top_albums call('tag.gettopalbums', :topalbums, Album, {:tag => @name}) end |
- (Object) top_artists
^ load_from_xml
53 54 55 |
# File 'lib/scrobbler/tag.rb', line 53 def top_artists call('tag.gettopartists', :topartists, Artist, {:tag => @name}) end |
- (Object) top_tracks
61 62 63 |
# File 'lib/scrobbler/tag.rb', line 61 def top_tracks call('tag.gettoptracks', :toptracks, Track, {:tag => @name}) end |
- (Object) weekly_artist_chart
81 82 83 84 |
# File 'lib/scrobbler/tag.rb', line 81 def weekly_artist_chart # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
- (Object) weekly_chart_list
86 87 88 89 |
# File 'lib/scrobbler/tag.rb', line 86 def weekly_chart_list # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |