Class: Lyrics::Response
- Inherits:
-
Object
- Object
- Lyrics::Response
- Defined in:
- lib/wiki_lyrics/lyrics.rb
Instance Attribute Summary collapse
-
#album ⇒ Object
, :suggestions.
-
#artist ⇒ Object
, :suggestions.
-
#custom_data ⇒ Object
, :suggestions.
-
#lyrics ⇒ Object
, :suggestions.
-
#request ⇒ Object
readonly
, :suggestions.
-
#title ⇒ Object
, :suggestions.
-
#url ⇒ Object
, :suggestions.
-
#year ⇒ Object
, :suggestions.
Instance Method Summary collapse
- #album_modified? ⇒ Boolean
- #artist_modified? ⇒ Boolean
- #each_modified ⇒ Object
- #each_modified! {|"artist", @artist| ... } ⇒ Object
-
#initialize(request) ⇒ Response
constructor
A new instance of Response.
- #title_modified? ⇒ Boolean
- #to_s ⇒ Object
- #year_modified? ⇒ Boolean
Constructor Details
#initialize(request) ⇒ Response
Returns a new instance of Response.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wiki_lyrics/lyrics.rb', line 61 def initialize( request ) raise "request can't be nil" if ! request @request = request @artist = nil @title = nil @album = nil @year = nil @lyrics = nil @custom_data = {} end |
Instance Attribute Details
#album ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def album @album end |
#artist ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def artist @artist end |
#custom_data ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def custom_data @custom_data end |
#lyrics ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def lyrics @lyrics end |
#request ⇒ Object (readonly)
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def request @request end |
#title ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def title @title end |
#url ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def url @url end |
#year ⇒ Object
, :suggestions
58 59 60 |
# File 'lib/wiki_lyrics/lyrics.rb', line 58 def year @year end |
Instance Method Details
#album_modified? ⇒ Boolean
112 113 114 |
# File 'lib/wiki_lyrics/lyrics.rb', line 112 def album_modified?() return @album && @album != request.album end |
#artist_modified? ⇒ Boolean
96 97 98 |
# File 'lib/wiki_lyrics/lyrics.rb', line 96 def artist_modified?() return @artist && @artist != request.artist end |
#each_modified ⇒ Object
92 93 94 |
# File 'lib/wiki_lyrics/lyrics.rb', line 92 def each_modified() each_modified!() { |k, v| yield k, v.clone() } end |
#each_modified! {|"artist", @artist| ... } ⇒ Object
85 86 87 88 89 90 |
# File 'lib/wiki_lyrics/lyrics.rb', line 85 def each_modified!() yield "artist", @artist if artist_modified?() yield "title", @title if title_modified?() yield "album", @album if album_modified?() yield "year", @year if year_modified?() end |
#title_modified? ⇒ Boolean
104 105 106 |
# File 'lib/wiki_lyrics/lyrics.rb', line 104 def title_modified?() return @title && @title != request.title end |
#to_s ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/wiki_lyrics/lyrics.rb', line 72 def to_s() ret = "" ret << "\n - response artist: #{@artist}" if @artist ret << "\n - response title: #{@title}" if @title ret << "\n - response album: #{@album}" if @album ret << "\n - response year: #{@year}" if @year if @custom_data.size > 0 ret << "\n - response custom data:" @custom_data.each { |key, val| ret << "\n - #{key}: #{val}" } end return ret.size > 0 ? ret.slice( 1..-1 ) : ret end |
#year_modified? ⇒ Boolean
120 121 122 |
# File 'lib/wiki_lyrics/lyrics.rb', line 120 def year_modified?() return @year && @year != request.year end |