lib/soundcloud/models/user.rb in soundcloud-ruby-api-wrapper-0.1.3 vs lib/soundcloud/models/user.rb in soundcloud-ruby-api-wrapper-0.1.5
- old
+ new
@@ -1,39 +1,54 @@
module Soundcloud
module Models
# Soundcloud User resource
#
+ # Look up the resource attributes and filtering usage here:
+ #
# http://wiki.github.com/soundcloud/api/documentation#user
#
# Examples:
- # user = client.User.find('userABC')
- # => gets the user with username userABC
- #
- # erics = client.User.find(:all, :params=> {:q => "eric"})
- # erics.each do |user|
+ # # gets the user with username userABC
+ # user = sc_client.User.find('userABC')
+ #
+ # # finds all users named joe and print their usernames
+ # joes = sc_client.User.find(:all, :params=> {:q => "joe"})
+ # joes.each do |user|
# p user.username
# end
- # => finds all users named eric and print their usernames
#
- # me = client.User.find(:one, :from => '/me')
- # => gets the logged-in user
+ # # gets the logged-in user
+ # me = client.User.find_me
#
- # eric1 = erics.first
- # eric2 = erics[1]
- # eric1.has_contact?(eric2)
- # => checks if the first user named eric is following the second user named eric
+ # # checks if the first user named joe is following the second user named joe
+ # joe1 = joes.first
+ # joe2 = joes[1]
+ # joe1.has_contact?(joe2)
#
- # eric2.add_contact!
- # => makes the loggedin user following eric2
+ # # makes the loggedin user following joe2
+ # joe2.add_contact!
+ #
+ #
+ # # Display all tracks of a user
+ # user = sc_client.User.find('some-user')
+ # user.tracks.each do |track|
+ # p track.title
+ # end
+
class User < Base
has_many :tracks, :contacts, :comments, :favorites, :playlists
has_many_single_changeable :contacts, :favorites
can_be_a_single_changeable :contact
cattr_accessor :element_name
self.element_name = 'user'
+
+ # Convenience method to find the logged in user
+ def self.find_me
+ find(:one, :from => '/me')
+ end
end
class Permission < User #:nodoc:
end