Class: Rocksky::Agent
- Inherits:
-
Object
- Object
- Rocksky::Agent
- Defined in:
- lib/rocksky.rb
Overview
---- authenticated agent ----
Records are passed as Hashes with camelCase keys (title, artist, album, albumArtist, durationMs, …), matching the wire record shape.
Class Method Summary collapse
Instance Method Summary collapse
-
#close ⇒ Object
Release the native handle.
- #follow(did) ⇒ Object
-
#initialize(ptr) ⇒ Agent
constructor
A new instance of Agent.
- #like(uri, cid) ⇒ Object
- #refresh_session ⇒ Object
-
#scrobble(track) ⇒ Object
Scrobble a play; fans out to artist/album/song/scrobble.
- #shout(subject_uri, subject_cid, message) ⇒ Object
Constructor Details
#initialize(ptr) ⇒ Agent
Returns a new instance of Agent.
102 103 104 |
# File 'lib/rocksky.rb', line 102 def initialize(ptr) @ptr = ptr end |
Class Method Details
.login(session_path, identifier, password, appview: nil) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/rocksky.rb', line 95 def self.login(session_path, identifier, password, appview: nil) ptr = C.rocksky_agent_login(session_path, identifier, password, appview.to_s) raise Error, (Rocksky.take_string(C.rocksky_last_error()) || "login failed") if ptr.null? new(ptr) end |
Instance Method Details
#close ⇒ Object
Release the native handle. The agent is unusable afterwards.
128 129 130 131 132 133 |
# File 'lib/rocksky.rb', line 128 def close return if @ptr.null? C.rocksky_agent_free(@ptr) @ptr = Fiddle::Pointer.new(0) end |
#follow(did) ⇒ Object
115 116 117 |
# File 'lib/rocksky.rb', line 115 def follow(did) Rocksky.unwrap(C.rocksky_agent_follow(@ptr, did)) end |
#like(uri, cid) ⇒ Object
111 112 113 |
# File 'lib/rocksky.rb', line 111 def like(uri, cid) Rocksky.unwrap(C.rocksky_agent_like(@ptr, uri, cid)) end |
#refresh_session ⇒ Object
123 124 125 |
# File 'lib/rocksky.rb', line 123 def refresh_session Rocksky.unwrap(C.rocksky_agent_refresh_session(@ptr)) end |