Class: Atradio::Agent
- Inherits:
-
Object
- Object
- Atradio::Agent
- Defined in:
- lib/atradio.rb
Overview
---- authenticated agent ----
Stations are passed as Hashes with camelCase keys (stationId, name, streamUrl, source, …), matching the wire record shape.
Class Method Summary collapse
Instance Method Summary collapse
-
#close ⇒ Object
Release the native handle.
- #comment(station, text) ⇒ Object
- #delete_play_status ⇒ Object
- #favorite(station) ⇒ Object
-
#initialize(ptr) ⇒ Agent
constructor
A new instance of Agent.
- #refresh_session ⇒ Object
- #set_play_status(station) ⇒ Object
- #unfavorite(station) ⇒ Object
Constructor Details
#initialize(ptr) ⇒ Agent
Returns a new instance of Agent.
111 112 113 |
# File 'lib/atradio.rb', line 111 def initialize(ptr) @ptr = ptr end |
Class Method Details
.login(session_path, identifier, password, appview: nil) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/atradio.rb', line 102 def self.login(session_path, identifier, password, appview: nil) ptr = C.atradio_agent_login(session_path, identifier, password, appview.to_s) if ptr.null? raise Error, (Atradio.take_string(C.atradio_last_error()) || "login failed") end new(ptr) end |
Instance Method Details
#close ⇒ Object
Release the native handle. The agent is unusable afterwards.
140 141 142 143 144 145 |
# File 'lib/atradio.rb', line 140 def close return if @ptr.null? C.atradio_agent_free(@ptr) @ptr = Fiddle::Pointer.new(0) end |
#comment(station, text) ⇒ Object
123 124 125 |
# File 'lib/atradio.rb', line 123 def comment(station, text) Atradio.unwrap(C.atradio_agent_comment(@ptr, JSON.generate(station), text)) end |
#delete_play_status ⇒ Object
131 132 133 |
# File 'lib/atradio.rb', line 131 def delete_play_status Atradio.unwrap(C.atradio_agent_delete_play_status(@ptr)) end |
#favorite(station) ⇒ Object
115 116 117 |
# File 'lib/atradio.rb', line 115 def favorite(station) Atradio.unwrap(C.atradio_agent_favorite(@ptr, JSON.generate(station))) end |
#refresh_session ⇒ Object
135 136 137 |
# File 'lib/atradio.rb', line 135 def refresh_session Atradio.unwrap(C.atradio_agent_refresh_session(@ptr)) end |