Class: Rdio::User

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

Overview


Represents an Rdio user


Instance Attribute Summary collapse

Attributes inherited from UserData

#base_icon, #display_name, #first_name, #gender, #icon, #last_name, #last_song_play_time, #last_song_played, #library_version, #track_count, #type, #url, #username

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) ⇒ User

Returns a new instance of User.



421
422
423
# File 'lib/rdio/types.rb', line 421

def initialize(api)
  super api
end

Instance Attribute Details

#is_subscriberObject

isSubscriber



429
430
431
# File 'lib/rdio/types.rb', line 429

def is_subscriber
  @is_subscriber
end

#is_trialObject

isTrial



426
427
428
# File 'lib/rdio/types.rb', line 426

def is_trial
  @is_trial
end

#is_unlimitedObject

isUnlimited



432
433
434
# File 'lib/rdio/types.rb', line 432

def is_unlimited
  @is_unlimited
end

Class Method Details

.add_friend(user) ⇒ Object

Add a friend to the current user.



525
526
527
# File 'lib/rdio/types.rb', line 525

def self.add_friend(user)
  Rdio::api.addFriend user
end

.add_playlists_to_collection(playlists) ⇒ Object

Add playlists to the current user’s collection.



560
561
562
# File 'lib/rdio/types.rb', line 560

def self.add_playlists_to_collection(playlists)
  add_to_collection playlists
end

.add_to_collection(objs) ⇒ Object

Add tracks or playlists to the current user’s collection.



550
551
552
# File 'lib/rdio/types.rb', line 550

def self.add_to_collection(objs)
  Rdio::api.addToCollection objs
end

.add_tracks_to_collection(tracks) ⇒ Object

Add tracks to the current user’s collection.



555
556
557
# File 'lib/rdio/types.rb', line 555

def self.add_tracks_to_collection(tracks)
  add_to_collection tracks
end

.all(keys, extras = nil) ⇒ Object

Fetch one or more objects from Rdio of type User.



482
483
484
# File 'lib/rdio/types.rb', line 482

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

.current(extras = nil) ⇒ Object

Get information about the currently logged in user.



462
463
464
# File 'lib/rdio/types.rb', line 462

def self.current(extras=nil)
  Rdio::api.currentUser extras
end

.find(s) ⇒ Object

Finds the user by email or vanity name



477
478
479
# File 'lib/rdio/types.rb', line 477

def self.find(s)
  s =~ /@/ ? find_by_email(s) : find_by_vanity_name(s)
end

.find_by_email(email) ⇒ Object

Find a user either by email address.



467
468
469
# File 'lib/rdio/types.rb', line 467

def self.find_by_email(email)
  Rdio::api.findUserByEmail email
end

.find_by_vanity_name(name) ⇒ Object

Find a user either by email address.



472
473
474
# File 'lib/rdio/types.rb', line 472

def self.find_by_vanity_name(name)
  Rdio::api.findUserByVanityName name
end

.from_short_code(short_code) ⇒ Object

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



584
585
586
# File 'lib/rdio/types.rb', line 584

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

.from_url(url) ⇒ Object

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



590
591
592
# File 'lib/rdio/types.rb', line 590

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

.get(key, extras = nil) ⇒ Object

Fetch one object from Rdio of type User.



487
488
489
490
# File 'lib/rdio/types.rb', line 487

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

.playlists(extras = nil) ⇒ Object

Get the current user’s playlists.



595
596
597
# File 'lib/rdio/types.rb', line 595

def self.playlists(extras=nil)
  Rdio::api.getPlaylists extras
end

.remove_friend(user) ⇒ Object

Remove a friend from the current user.



530
531
532
# File 'lib/rdio/types.rb', line 530

def self.remove_friend(user)
  Rdio::api.removeFriend user
end

.remove_from_collection(objs) ⇒ Object

Remove tracks or playlists from the current user’s collection.



535
536
537
# File 'lib/rdio/types.rb', line 535

def self.remove_from_collection(objs)
  Rdio::api.removeFromCollection objs
end

.remove_playlists_from_collection(playlists) ⇒ Object

Remove playlistsfrom the current user’s collection.



545
546
547
# File 'lib/rdio/types.rb', line 545

def self.remove_playlists_from_collection(playlists)
  remove_from_collection playlists
end

.remove_tracks_from_collection(tracks) ⇒ Object

Remove tracks from the current user’s collection.



540
541
542
# File 'lib/rdio/types.rb', line 540

def self.remove_tracks_from_collection(tracks)
  remove_from_collection tracks
end

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

Returns an array of User for the query and other params



456
457
458
459
# File 'lib/rdio/types.rb', line 456

def self.search(query,never_or=nil,extras=nil,start=nil,count=nil)
  extras = Rdio::add_to_array extras,'users'
  Search.search query,User,never_or,extras,start,count
end

.top_chartsObject

Return the site-wide most popular items for Users



600
601
602
# File 'lib/rdio/types.rb', line 600

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

Instance Method Details

#activity_stream(scope = 'user', last_id = nil) ⇒ Object

Get the activity events for a user, a user’s friends, or everyone on Rdio.



451
452
453
# File 'lib/rdio/types.rb', line 451

def activity_stream(scope='user',last_id=nil)
  api.getActivityStream self,scope,last_id
end

#albums_for_artist_in_collection(artist) ⇒ Object

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



498
499
500
# File 'lib/rdio/types.rb', line 498

def albums_for_artist_in_collection(artist)
  api.getAlbumsForArtistInCollection artist,self
end

#albums_heavy_rotation(friends = nil, limit = nil) ⇒ Object

Find the most popular albums for a user, their friends or the whole site.



578
579
580
# File 'lib/rdio/types.rb', line 578

def albums_heavy_rotation(friends=nil,limit=nil)
  api.getHeavyRotation self,Album,friends,limit
end

#albums_in_collection(start = nil, count = nil, sort = nil, query = nil) ⇒ Object

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



493
494
495
# File 'lib/rdio/types.rb', line 493

def albums_in_collection(start=nil,count=nil,sort=nil,query=nil)
  api.getAlbumsInCollection self,start,count,sort,query
end

#artists_heavy_rotation(friends = nil, limit = nil) ⇒ Object

Find the most popular artists for a user, their friends or the whole site.



572
573
574
# File 'lib/rdio/types.rb', line 572

def artists_heavy_rotation(friends=nil,limit=nil)
  api.getHeavyRotation self,Artist,friends,limit
end

#artists_in_collection(start = nil, count = nil, sort = nil, query = nil, extras = nil) ⇒ Object

Get all of the artist in a user’s collection.



503
504
505
506
# File 'lib/rdio/types.rb', line 503

def artists_in_collection(start=nil,count=nil,sort=nil,
                          query=nil,extras=nil)
  api.getArtistsInCollection self,start,count,sort,query,extras
end

#heavy_rotation(friends = nil, limit = nil, extras = nil) ⇒ Object

Find the most popular artists or albums for a user, their friends or the whole site.



566
567
568
# File 'lib/rdio/types.rb', line 566

def heavy_rotation(friends=nil,limit=nil,extras=nil)
  api.getHeavyRotation self,nil,friends,limit,extras
end

#subscriber?Boolean

isSubscriber

Returns:



440
441
442
# File 'lib/rdio/types.rb', line 440

def subscriber?
  is_subscriber
end

#tracks_for_album_in_collection(album, extras = nil) ⇒ Object

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



520
521
522
# File 'lib/rdio/types.rb', line 520

def tracks_for_album_in_collection(album,extras=nil)
  api.getTracksForAlbumInCollection album,self,extras
end

#tracks_for_artist_in_collection(artist, extras = nil) ⇒ Object

Which tracks from the given artist are in the user’s collection.



509
510
511
# File 'lib/rdio/types.rb', line 509

def tracks_for_artist_in_collection(artist,extras=nil)
  api.getTracksForArtistInCollection artist,self,extras
end

#tracks_in_collection(start = nil, count = nil, sort = nil, query = nil, extras = nil) ⇒ Object

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



514
515
516
517
# File 'lib/rdio/types.rb', line 514

def tracks_in_collection(start=nil,count=nil,sort=nil,
                         query=nil,extras=nil)
  api.getTracksInCollection self,start,count,sort,query,extras
end

#trial?Boolean

isTrial

Returns:



435
436
437
# File 'lib/rdio/types.rb', line 435

def trial?
  is_trial
end

#unlimited?Boolean

isUnlimited

Returns:



445
446
447
# File 'lib/rdio/types.rb', line 445

def unlimited?
  is_unlimited
end