Class: Vagalume::SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/vagalume/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ SearchResult

Returns a new instance of SearchResult.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/vagalume/search_result.rb', line 5

def initialize(result)
  @translations = []
  @status = result["type"]
  return if not_found?

  song = result["mus"].first
  artist = result["art"]
  translations = song["translate"] || []
  @song = Vagalume::Song.new(song)
  @artist = Vagalume::Artist.new(artist)

  translations.each do |translation|
    @translations << Vagalume::Song.new(translation)
  end
end

Instance Attribute Details

#artistObject

Returns the value of attribute artist.



3
4
5
# File 'lib/vagalume/search_result.rb', line 3

def artist
  @artist
end

#songObject

Returns the value of attribute song.



3
4
5
# File 'lib/vagalume/search_result.rb', line 3

def song
  @song
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/vagalume/search_result.rb', line 3

def status
  @status
end

#translationsObject

Returns the value of attribute translations.



3
4
5
# File 'lib/vagalume/search_result.rb', line 3

def translations
  @translations
end

Instance Method Details

#not_found?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/vagalume/search_result.rb', line 21

def not_found?
   @status == Vagalume::Status::NOT_FOUND ||
   @status == Vagalume::Status::SONG_NOT_FOUND
end