Module: Atradio
- Defined in:
- lib/atradio.rb,
lib/atradio.rb,
lib/atradio/native.rb
Defined Under Namespace
Modules: Native Classes: Agent, Error
Constant Summary collapse
- VERSION =
"0.1.0"- LIB_PATH =
Local dev build if present, else a checksum-verified download from the GitHub release (cached). See Atradio::Native.
Native.resolve
Class Method Summary collapse
-
.favorite_rkey(station_id) ⇒ Object
The deterministic favorite record key — identical across every atradio SDK.
- .favorites(actor, limit = 50, base: nil) ⇒ Object
- .global_recently_played(limit = 50, base: nil) ⇒ Object
- .popular_stations(limit = 50, base: nil) ⇒ Object
-
.recent_stations(limit = 50, base: nil) ⇒ Object
---- reads (unauthenticated) ----.
-
.take_string(ptr) ⇒ Object
Copy an owned C string into a Ruby string and free the original.
-
.unwrap(ptr) ⇒ Object
Parse a
{"ok"|"error"}envelope, raising Error on failure.
Class Method Details
.favorite_rkey(station_id) ⇒ Object
The deterministic favorite record key — identical across every atradio SDK.
93 94 95 |
# File 'lib/atradio.rb', line 93 def self.favorite_rkey(station_id) take_string(C.atradio_favorite_rkey(station_id)) end |
.favorites(actor, limit = 50, base: nil) ⇒ Object
88 89 90 |
# File 'lib/atradio.rb', line 88 def self.favorites(actor, limit = 50, base: nil) unwrap(C.atradio_favorites(base.to_s, actor, limit)) end |
.global_recently_played(limit = 50, base: nil) ⇒ Object
84 85 86 |
# File 'lib/atradio.rb', line 84 def self.global_recently_played(limit = 50, base: nil) unwrap(C.atradio_global_recently_played(base.to_s, limit)) end |
.popular_stations(limit = 50, base: nil) ⇒ Object
80 81 82 |
# File 'lib/atradio.rb', line 80 def self.popular_stations(limit = 50, base: nil) unwrap(C.atradio_popular_stations(base.to_s, limit)) end |
.recent_stations(limit = 50, base: nil) ⇒ Object
---- reads (unauthenticated) ----
76 77 78 |
# File 'lib/atradio.rb', line 76 def self.recent_stations(limit = 50, base: nil) unwrap(C.atradio_recent_stations(base.to_s, limit)) end |
.take_string(ptr) ⇒ Object
Copy an owned C string into a Ruby string and free the original.
57 58 59 60 61 62 63 64 |
# File 'lib/atradio.rb', line 57 def self.take_string(ptr) return nil if ptr.nil? || ptr.null? len = STRLEN.call(ptr) str = ptr[0, len].force_encoding("UTF-8") C.atradio_string_free(ptr) str end |
.unwrap(ptr) ⇒ Object
Parse a {"ok"|"error"} envelope, raising Error on failure.
67 68 69 70 71 72 |
# File 'lib/atradio.rb', line 67 def self.unwrap(ptr) parsed = JSON.parse(take_string(ptr)) raise Error, parsed["error"] if parsed.key?("error") parsed["ok"] end |