Class: Vagalume::SearchResult
- Inherits:
-
Object
- Object
- Vagalume::SearchResult
- Defined in:
- lib/vagalume/search_result.rb
Instance Attribute Summary collapse
-
#artist ⇒ Object
Returns the value of attribute artist.
-
#song ⇒ Object
Returns the value of attribute song.
-
#status ⇒ Object
Returns the value of attribute status.
-
#translations ⇒ Object
Returns the value of attribute translations.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize ⇒ SearchResult
Returns a new instance of SearchResult.
5 6 7 |
# File 'lib/vagalume/search_result.rb', line 5 def initialize @translations = [] end |
Instance Attribute Details
#artist ⇒ Object
Returns the value of attribute artist.
3 4 5 |
# File 'lib/vagalume/search_result.rb', line 3 def artist @artist end |
#song ⇒ Object
Returns the value of attribute song.
3 4 5 |
# File 'lib/vagalume/search_result.rb', line 3 def song @song end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/vagalume/search_result.rb', line 3 def status @status end |
#translations ⇒ Object
Returns the value of attribute translations.
3 4 5 |
# File 'lib/vagalume/search_result.rb', line 3 def translations @translations end |
Class Method Details
.fetch(result_json) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagalume/search_result.rb', line 9 def self.fetch(result_json) result = Vagalume::SearchResult.new result.status = result_json["type"] return result if result.status == Vagalume::Status::NOT_FOUND || result.status == Vagalume::Status::SONG_NOT_FOUND song = result_json["mus"].first artist = result_json["art"] translations = song["translate"] || [] result.song = Vagalume::Song.fetch(song) result.artist = Vagalume::Artist.fetch(artist) translations.each do |translation| result.translations << Vagalume::Song.fetch(translation) end result end |