Class: Hallon::User
- Defined in:
- lib/hallon/user.rb
Overview
Users are the entities that interact with the Spotify service.
Methods are available for retrieving metadata and relationship status between users.
Defined Under Namespace
Classes: Post
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#display_name ⇒ String
Display name of the User.
-
#from_link ⇒ Spotify::Link
private
Pointer representation of given link.
-
#initialize(link) ⇒ User
constructor
Construct a new instance of User.
-
#loaded? ⇒ Boolean
True if the user is loaded.
-
#name ⇒ String
Canonical name of the User.
-
#post(message = nil, tracks) ⇒ Post?
Send tracks to this users’ inbox, with an optional message.
-
#published ⇒ PlaylistContainer?
Published playlists of the User.
-
#starred ⇒ Playlist?
Starred playlist of the User.
-
#to_link ⇒ Hallon::Link
Link for the current object.
Methods included from Loadable
Methods included from Linkable
Methods inherited from Base
#==, from, from_link, #is_linkable?, #session, to_link, #to_pointer, #to_s
Constructor Details
#initialize(link) ⇒ User
You can also instantiate User with a canonical username
Construct a new instance of User.
90 91 92 93 94 95 96 |
# File 'lib/hallon/user.rb', line 90 def initialize(link) @pointer = to_pointer(link, Spotify::User) do if link.is_a?(String) and link !~ /\Aspotify:user:/ to_pointer("spotify:user:#{link}", Spotify::User) end end end |
Instance Method Details
#display_name ⇒ String
110 111 112 |
# File 'lib/hallon/user.rb', line 110 def display_name Spotify.user_display_name(pointer) end |
#from_link ⇒ Spotify::Link (private)
Returns pointer representation of given link.
74 75 76 |
# File 'lib/hallon/user.rb', line 74 from_link :profile do |link| Spotify.link_as_user(link) end |
#loaded? ⇒ Boolean
Returns true if the user is loaded.
99 100 101 |
# File 'lib/hallon/user.rb', line 99 def loaded? Spotify.user_is_loaded(pointer) end |
#name ⇒ String
Returns canonical name of the User.
104 105 106 |
# File 'lib/hallon/user.rb', line 104 def name Spotify.user_canonical_name(pointer) end |
#post(message, tracks) ⇒ Post? #post(tracks) ⇒ Post?
Send tracks to this users’ inbox, with an optional message.
138 139 140 |
# File 'lib/hallon/user.rb', line 138 def post( = nil, tracks) Post.create(name, , tracks) end |
#published ⇒ PlaylistContainer?
Returns nil unless #loaded?
Returns published playlists of the User.
123 124 125 126 |
# File 'lib/hallon/user.rb', line 123 def published container = Spotify.session_publishedcontainer_for_user_create(session.pointer, name) PlaylistContainer.from(container) end |
#starred ⇒ Playlist?
Returns nil unless #loaded?
Returns starred playlist of the User.
116 117 118 119 |
# File 'lib/hallon/user.rb', line 116 def starred playlist = Spotify.session_starred_for_user_create(session.pointer, name) Playlist.from(playlist) end |
#to_link ⇒ Hallon::Link
Returns Link for the current object.
78 |
# File 'lib/hallon/user.rb', line 78 to_link :from_user |