Class: LyricsSearch::SearchResults::SearchResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ SearchResult

Returns a new instance of SearchResult.



4
5
6
7
8
9
10
11
# File 'lib/lyrics_search/search_result.rb', line 4

def initialize(result)
  @artist, @song, @lyric_id, @lyric_checksum = result.values_at(:artist, :song, :lyric_id, :lyric_checksum)
  
  @raw_result = LyricsSearch::CHARTLYRICS_CLIENT.call(:get_lyric, message: {lyric_id: @lyric_id, lyric_check_sum: @lyric_checksum}).
                                                 body.dig(:get_lyric_response, :get_lyric_result)

  @lyrics = @raw_result[:lyric]
end

Instance Attribute Details

#artistObject (readonly)

Returns the value of attribute artist.



2
3
4
# File 'lib/lyrics_search/search_result.rb', line 2

def artist
  @artist
end

#lyricsObject (readonly)

Returns the value of attribute lyrics.



2
3
4
# File 'lib/lyrics_search/search_result.rb', line 2

def lyrics
  @lyrics
end

#raw_resultObject (readonly)

Returns the value of attribute raw_result.



2
3
4
# File 'lib/lyrics_search/search_result.rb', line 2

def raw_result
  @raw_result
end

#songObject (readonly)

Returns the value of attribute song.



2
3
4
# File 'lib/lyrics_search/search_result.rb', line 2

def song
  @song
end

Instance Method Details

#get_resultObject



13
14
15
# File 'lib/lyrics_search/search_result.rb', line 13

def get_result
  {artist: artist, song: song, lyrics: lyrics}
end