Class: Vk::Audio
- Defined in:
- lib/vk/audio.rb,
lib/vk/audio/album.rb,
lib/vk/audio/lyrics.rb
Defined Under Namespace
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
Instance Method Summary collapse
- #album ⇒ Vk::Audio::Album
- #genre ⇒ String
- #genre=(genre) ⇒ Integer
- #lyrics ⇒ String
- #owner ⇒ Vk::User
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
#album ⇒ Vk::Audio::Album
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=(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 |