Class: Vk::Audio
- Inherits:
-
Base
show all
- Defined in:
- lib/vk/audio.rb,
lib/vk/audio/album.rb,
lib/vk/audio/lyrics.rb
Defined Under Namespace
Classes: Album, Lyrics
Constant Summary
collapse
- GENRES =
{
1 => 'Rock',
2 => 'Pop',
3 => 'Rap & Hip-Hop',
4 => 'Easy Listening',
5 => 'House & Dance',
6 => 'Instrumental',
7 => 'Metal',
21 => 'Alternative',
8 => 'Dubstep',
1001 => 'Jazz & Blues',
10 => 'Drum & Bass',
11 => 'Trance',
12 => 'Chanson',
13 => 'Ethnic',
14 => 'Acoustic & Vocal',
15 => 'Reggae',
16 => 'Classical',
17 => 'Indie Pop',
19 => 'Speech',
22 => 'Electropop & Disco',
18 => 'Other',
}
Instance Attribute Summary
Attributes inherited from Base
#attributes
Instance Method Summary
collapse
Methods inherited from Base
#fields, find, #id, #id=, #identity_map, inherited, #initialize, #inspect, #key_field, #loader, #logger, method_missing, #method_missing, #read_attribute, #respond_to_missing?, #to_hash
Constructor Details
This class inherits a constructor from Vk::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Vk::Base
Instance Method Details
44
45
46
47
|
# File 'lib/vk/audio.rb', line 44
def album
album_id = read_attribute(:album_id).to_s
@album ||= owner.audio_albums.detect { |album| album.id.to_s == album_id }
end
|
#genre ⇒ String
55
56
57
|
# File 'lib/vk/audio.rb', line 55
def genre
GENRES[genre_id]
end
|
#genre=(genre) ⇒ Integer
66
67
68
|
# File 'lib/vk/audio.rb', line 66
def genre=(genre)
self.genre_id = GENRES.key(genre)
end
|
#lyrics ⇒ String
60
61
62
|
# File 'lib/vk/audio.rb', line 60
def lyrics
@lyrics ||= loader.get_lyrics(lyrics_id).text if lyrics_id
end
|
50
51
52
|
# File 'lib/vk/audio.rb', line 50
def owner
@owner ||= Vk::User.find(owner_id)
end
|