Sha256: b7a105f56d8e9566e8116cc49b766e1e3e3518fa3ffb07abef39075747bc760d
Contents?: true
Size: 629 Bytes
Versions: 3
Compression:
Stored size: 629 Bytes
Contents
# frozen_string_literal: true module AppleMusic # https://developer.apple.com/documentation/applemusicapi/chartresponse class ChartResponse attr_reader :albums, :music_videos, :songs, :playlists def initialize(props = {}) @albums = build_chart(props['albums'])&.data || [] @music_videos = build_chart(props['music-videos'])&.data || [] @songs = build_chart(props['songs'])&.data || [] @playlists = build_chart(props['playlists'])&.data || [] end private def build_chart(resources) Array(resources).map { |props| Chart.new(props) }.first end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
apple_music-0.3.1 | lib/apple_music/chart_response.rb |
apple_music-0.3.0 | lib/apple_music/chart_response.rb |
apple_music-0.2.0 | lib/apple_music/chart_response.rb |