Class: Rdio::Album

Inherits:
AlbumData show all
Defined in:
lib/rdio/types.rb

Overview


Represents a recording on Rdio, usually an album but often a single, EP or compilation


Instance Attribute Summary collapse

Attributes inherited from AlbumData

#artist_key, #artist_url, #base_icon, #can_sample, #can_stream, #can_tether, #display_date, #duration, #embed_url, #icon, #is_clean, #is_explicit, #length, #name, #price, #release_date, #release_date_iso, #short_url, #track_keys, #type, #url

Attributes inherited from BaseObj

#key

Attributes inherited from ApiObj

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObj

#eql?, #to_k

Methods inherited from ApiObj

#fill

Constructor Details

#initialize(api) ⇒ Album

Returns a new instance of Album.



95
96
97
# File 'lib/rdio/types.rb', line 95

def initialize(api)
  super api
end

Instance Attribute Details

#secondary_idObject

the secondary id



103
104
105
# File 'lib/rdio/types.rb', line 103

def secondary_id
  @secondary_id
end

#track_idsObject

the track ids



100
101
102
# File 'lib/rdio/types.rb', line 100

def track_ids
  @track_ids
end

#tracks(extras = nil) ⇒ Object

Return an array of Track



106
107
108
# File 'lib/rdio/types.rb', line 106

def tracks
  @tracks
end

Class Method Details

.all(keys, extras = nil) ⇒ Object

Fetch one or more objects from Rdio of type Album.



140
141
142
# File 'lib/rdio/types.rb', line 140

def self.all(keys,extras=nil)
  Rdio::api.get keys,Album,extras
end

.for_artist(artist, featuring = nil, extras = nil, start = nil, count = nil) ⇒ Object

Return the albums by (or featuring) an artist.



151
152
153
# File 'lib/rdio/types.rb', line 151

def self.for_artist(artist,featuring=nil,extras=nil,start=nil,count=nil)
  Rdio::api.getAlbumsForArtist artist,featuring,extras,start,count
end

.for_artist_in_collection(artist, user = nil) ⇒ Object

Get the albums in the user’s collection by a particular artist.



156
157
158
# File 'lib/rdio/types.rb', line 156

def self.for_artist_in_collection(artist,user=nil)
  Rdio::api.getAlbumsForArtistInCollection artist,user
end

.from_short_code(short_code) ⇒ Object

Return the Albums that the supplied Rdio short-code is a representation of, or null if the short-code is invalid.



173
174
175
# File 'lib/rdio/types.rb', line 173

def self.from_short_code(short_code)
  Rdio::api.getObjectFromShortCode short_code,Album
end

.from_url(url) ⇒ Object

Return the Album that the supplied Rdio url is a representation of, or null if the url doesn’t represent an object.



179
180
181
# File 'lib/rdio/types.rb', line 179

def self.from_url(url)
  Rdio::api.getObjectFromUrl url,Album
end

.get(key, extras = nil) ⇒ Object

Fetch one object from Rdio of type Album.



145
146
147
148
# File 'lib/rdio/types.rb', line 145

def self.get(key,extras=nil)
  arr = all [key],extras
  (arr and not arr.empty?) ? arr[0] : nil
end

.in_collection(user = nil, start = nil, count = nil, sort = nil, query = nil) ⇒ Object

Get all of the albums in the user’s collection.



161
162
163
164
# File 'lib/rdio/types.rb', line 161

def self.in_collection(user=nil,start=nil,count=nil,
                      sort=nil,query=nil)
  Rdio::api.getAlbumsInCollection user,start,count,sort,query
end

.new_releases(time) ⇒ Object

Return new albums released across a timeframe.



167
168
169
# File 'lib/rdio/types.rb', line 167

def self.new_releases(time)
  Rdio::api.getNewReleases time
end

.search(query, never_or = nil, extras = nil, start = nil, count = nil) ⇒ Object

Returns an array of Album for the query and other params



134
135
136
137
# File 'lib/rdio/types.rb', line 134

def self.search(query,never_or=nil,extras=nil,start=nil,count=nil)
  extras = add_to_array extras,'albums'
  Search.search query,Album,never_or,extras,start,count
end

.top_chartsObject

Return the site-wide most popular items for Albums



184
185
186
# File 'lib/rdio/types.rb', line 184

def self.top_charts
  Rdio::api.getTopCharts Album
end

Instance Method Details

#artistObject

Returns the Artist



119
120
121
# File 'lib/rdio/types.rb', line 119

def artist
  Artist.get artist_key
end

#artist_nameObject

Returns the String artist name



124
125
126
# File 'lib/rdio/types.rb', line 124

def artist_name
  @artist
end

#clean?Boolean

is the album clean

Returns:



114
115
116
# File 'lib/rdio/types.rb', line 114

def clean?
  is_clean
end

#explicit?Boolean

is the album explicit?

Returns:



109
110
111
# File 'lib/rdio/types.rb', line 109

def explicit?
  is_explicit
end

#tracks_in_collection(user = nil, extras = nil) ⇒ Object

Which tracks on the given album are in the user’s collection.



189
190
191
# File 'lib/rdio/types.rb', line 189

def tracks_in_collection(user=nil,extras=nil)
  api.getTracksForAlbumInCollection self,user,extras
end