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.



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

def initialize(api)
  super api
end

Instance Attribute Details

#big_iconObject

big icon



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

def big_icon
  @big_icon
end

#is_compilationObject

indicates if the album is a compilation



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

def is_compilation
  @is_compilation
end

#secondary_idObject

the secondary id



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

def secondary_id
  @secondary_id
end

#track_idsObject

the track ids



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

def track_ids
  @track_ids
end

#tracks(extras = nil) ⇒ Object

Return an array of Track



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

def tracks
  @tracks
end

Class Method Details

.all(keys, extras = nil) ⇒ Object

Fetch one or more objects from Rdio of type Album.



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

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.



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

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, extras = nil) ⇒ Object

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



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

def self.for_artist_in_collection(artist,user=nil,extras=nil)
  Rdio::api.getAlbumsForArtistInCollection artist,user,extras
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.



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

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.



191
192
193
# File 'lib/rdio/types.rb', line 191

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

.get(key, extras = nil) ⇒ Object

Fetch one object from Rdio of type Album.



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

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, extras = nil) ⇒ Object

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



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

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

.new_releases(time) ⇒ Object

Return new albums released across a timeframe.



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

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



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

def self.search(query,never_or=nil,extras=nil,start=nil,count=nil)
  extras = Rdio::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



196
197
198
# File 'lib/rdio/types.rb', line 196

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

Instance Method Details

#artistObject

Returns the Artist



131
132
133
# File 'lib/rdio/types.rb', line 131

def artist
  Artist.get artist_key
end

#artist_nameObject

Returns the String artist name



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

def artist_name
  @artist
end

#clean?Boolean

is the album clean

Returns:



126
127
128
# File 'lib/rdio/types.rb', line 126

def clean?
  is_clean
end

#compilation?Boolean

indicates if the album is a compilation

Returns:



116
117
118
# File 'lib/rdio/types.rb', line 116

def compilation?
  is_compilation
end

#explicit?Boolean

is the album explicit?

Returns:



121
122
123
# File 'lib/rdio/types.rb', line 121

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.



201
202
203
# File 'lib/rdio/types.rb', line 201

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