Class: ListenBrainz::Artist
- Defined in:
- lib/listenbrainz/models/artist.rb
Overview
Model class for artists.
Defined Under Namespace
Classes: Payload
Instance Attribute Summary collapse
- #artist_mbid ⇒ String? (also: #mbid) readonly
- #artist_name ⇒ String (also: #name) readonly
- #listen_count ⇒ Integer readonly
Class Method Summary collapse
-
.get(username = ListenBrainz.client.username, count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves the top artists for a given user.
-
.sitewide(count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves site-wide top artists.
Methods inherited from Base
Instance Attribute Details
#artist_mbid ⇒ String? (readonly) Also known as: mbid
76 |
# File 'lib/listenbrainz/models/artist.rb', line 76 attribute? :artist_mbid, Types::String.optional |
#artist_name ⇒ String (readonly) Also known as: name
81 |
# File 'lib/listenbrainz/models/artist.rb', line 81 attribute :artist_name, Types::String |
#listen_count ⇒ Integer (readonly)
86 |
# File 'lib/listenbrainz/models/artist.rb', line 86 attribute :listen_count, Types::Integer |
Class Method Details
.get(username = ListenBrainz.client.username, count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves the top artists for a given user.
19 20 21 22 23 24 25 26 27 |
# File 'lib/listenbrainz/models/artist.rb', line 19 def self.get( username = ListenBrainz.client.username, count: nil, offset: nil, range: nil ) params = { count:, offset:, range: }.compact ListenBrainz.client.query( :get, "1/stats/user/#{username}/artists", params: ).fetch(:payload).then { Payload.new(_1) } end |
.sitewide(count: nil, offset: nil, range: nil) ⇒ Payload
Retrieves site-wide top artists.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/listenbrainz/models/artist.rb', line 38 def self.sitewide(count: nil, offset: nil, range: nil) params = { count:, offset:, range: }.compact payload = ListenBrainz.client.query( :get, '1/stats/sitewide/artists', params: ).fetch(:payload) # HACK: API is not consistent between site-wide and user schema. payload[:total_artist_count] = payload[:count] Payload.new(payload) end |