Class: VkMusic::WebParser::PlaylistSection

Inherits:
Base
  • Object
show all
Defined in:
lib/vk_music/web_parser/playlist_section.rb

Overview

PlaylistSection JSON parser

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from VkMusic::WebParser::Base

Instance Method Details

#audiosArray<Audio>

Returns:



13
14
15
16
17
18
19
# File 'lib/vk_music/web_parser/playlist_section.rb', line 13

def audios
  return unless data&.key?('list')

  data['list'].map do |el|
    Utility::AudioDataParser.call(el, @client_id)
  end
end

#dataObject

Parsed JSON



8
9
10
# File 'lib/vk_music/web_parser/playlist_section.rb', line 8

def data
  @data ||= json['data'].first || {}
end

#more?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/vk_music/web_parser/playlist_section.rb', line 46

def more?
  return unless data&.key?('hasMore')

  data['hasMore'].to_s == '1'
end

#real_sizeInteger?

Returns:

  • (Integer?)


39
40
41
42
43
# File 'lib/vk_music/web_parser/playlist_section.rb', line 39

def real_size
  return unless data&.key?('totalCount')

  data['totalCount']
end

#subtitleString?

Returns:

  • (String?)


29
30
31
32
33
34
35
36
# File 'lib/vk_music/web_parser/playlist_section.rb', line 29

def subtitle
  return unless data&.key?('rawDescription')

  re = data['rawDescription']
  return if re.nil? || re.empty?

  re
end

#titleString

Returns:

  • (String)


22
23
24
25
26
# File 'lib/vk_music/web_parser/playlist_section.rb', line 22

def title
  return unless data&.key?('title')

  data['title'].to_s
end