Class: AppleMusic::Chart
- Inherits:
-
Object
- Object
- AppleMusic::Chart
- Defined in:
- lib/apple_music/chart.rb
Overview
Instance Attribute Summary collapse
-
#chart ⇒ Object
readonly
Returns the value of attribute chart.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#next ⇒ Object
readonly
Returns the value of attribute next.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(props = {}) ⇒ Chart
constructor
A new instance of Chart.
Constructor Details
#initialize(props = {}) ⇒ Chart
Returns a new instance of Chart.
8 9 10 11 12 13 14 |
# File 'lib/apple_music/chart.rb', line 8 def initialize(props = {}) @chart = props['chart'] # required @data = Array(props['data']).map { |attrs| Resource.build(attrs) } # required @href = props['href'] # required @name = props['name'] # required @next = props['next'] end |
Instance Attribute Details
#chart ⇒ Object (readonly)
Returns the value of attribute chart.
6 7 8 |
# File 'lib/apple_music/chart.rb', line 6 def chart @chart end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/apple_music/chart.rb', line 6 def data @data end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
6 7 8 |
# File 'lib/apple_music/chart.rb', line 6 def href @href end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/apple_music/chart.rb', line 6 def name @name end |
#next ⇒ Object (readonly)
Returns the value of attribute next.
6 7 8 |
# File 'lib/apple_music/chart.rb', line 6 def next @next end |
Class Method Details
.list(**options) ⇒ Object
e.g. AppleMusic::Chart.list(types: [‘songs’, ‘albums’, ‘playlists’], genre: 20, limit: 30) developer.apple.com/documentation/applemusicapi/get_catalog_charts
19 20 21 22 23 24 25 26 |
# File 'lib/apple_music/chart.rb', line 19 def list(**) raise ParameterMissing, 'required parameter :types is missing' unless [:types] types = [:types].is_a?(Array) ? [:types].join(',') : [:types] storefront = Storefront.lookup(.delete(:storefront)) response = AppleMusic.get("catalog/#{storefront}/charts", .merge(types: types)) ChartResponse.new(response.body['results'] || {}) end |
.search(**_options) ⇒ Object
28 29 30 |
# File 'lib/apple_music/chart.rb', line 28 def search(**) warn 'WARN: :charts is not searchable resource' end |