Class: VkMusic::Playlist
- Inherits:
-
Object
- Object
- VkMusic::Playlist
- Includes:
- Enumerable
- Defined in:
- lib/vk_music/playlist.rb
Instance Attribute Summary collapse
-
#access_hash ⇒ Object
readonly
Returns the value of attribute access_hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#owner_id ⇒ Object
readonly
Returns the value of attribute owner_id.
-
#subtitle ⇒ Object
readonly
Returns the value of attribute subtitle.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(list, options = {}) ⇒ Playlist
constructor
A new instance of Playlist.
- #length ⇒ Object (also: #size)
- #to_s ⇒ Object
Constructor Details
#initialize(list, options = {}) ⇒ Playlist
Returns a new instance of Playlist.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vk_music/playlist.rb', line 29 def initialize(list, = {}) # Arguments check raise ArgumentError, "array of audios must be provided", caller unless list.class == Array # Saving list @list = list.dup # Setting up attributes @id = [:id].to_s @owner_id = [:owner_id].to_s @access_hash = [:access_hash].to_s @title = [:title].to_s @subtitle = [:subtitle].to_s end |
Instance Attribute Details
#access_hash ⇒ Object (readonly)
Returns the value of attribute access_hash.
6 7 8 |
# File 'lib/vk_music/playlist.rb', line 6 def access_hash @access_hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/vk_music/playlist.rb', line 6 def id @id end |
#owner_id ⇒ Object (readonly)
Returns the value of attribute owner_id.
6 7 8 |
# File 'lib/vk_music/playlist.rb', line 6 def owner_id @owner_id end |
#subtitle ⇒ Object (readonly)
Returns the value of attribute subtitle.
6 7 8 |
# File 'lib/vk_music/playlist.rb', line 6 def subtitle @subtitle end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/vk_music/playlist.rb', line 6 def title @title end |
Instance Method Details
#[](index) ⇒ Object
21 22 23 |
# File 'lib/vk_music/playlist.rb', line 21 def [](index) @list[index] end |
#each(&block) ⇒ Object
17 18 19 |
# File 'lib/vk_music/playlist.rb', line 17 def each(&block) @list.each(&block) end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/vk_music/playlist.rb', line 25 def empty? @list.empty? end |
#length ⇒ Object Also known as: size
8 9 10 |
# File 'lib/vk_music/playlist.rb', line 8 def length @list.length end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/vk_music/playlist.rb', line 13 def to_s "#{@subtitle} - #{@title} (#{self.length} аудиозаписей)" end |