Class: Lyrics::Request
- Inherits:
-
Object
- Object
- Lyrics::Request
- Defined in:
- lib/lyrics/lyrics.rb
Instance Attribute Summary collapse
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#fetch_data ⇒ Object
Returns the value of attribute fetch_data.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(artist, title, album = nil, year = nil) ⇒ Request
constructor
A new instance of Request.
- #to_s ⇒ Object
Constructor Details
#initialize(artist, title, album = nil, year = nil) ⇒ Request
Returns a new instance of Request.
38 39 40 41 42 43 44 45 |
# File 'lib/lyrics/lyrics.rb', line 38 def initialize( artist, title, album=nil, year=nil ) raise "target artist and title values can't be nil" if ! artist || ! title @artist = artist.clone().freeze() @title = title.clone().freeze() @album = album ? album.clone().freeze() : nil @year = year ? year.to_s().strip().to_i() : nil @fetch_data = nil end |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
35 36 37 |
# File 'lib/lyrics/lyrics.rb', line 35 def album @album end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
35 36 37 |
# File 'lib/lyrics/lyrics.rb', line 35 def artist @artist end |
#fetch_data ⇒ Object
Returns the value of attribute fetch_data.
35 36 37 |
# File 'lib/lyrics/lyrics.rb', line 35 def fetch_data @fetch_data end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
35 36 37 |
# File 'lib/lyrics/lyrics.rb', line 35 def title @title end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
35 36 37 |
# File 'lib/lyrics/lyrics.rb', line 35 def year @year end |
Instance Method Details
#to_s ⇒ Object
47 48 49 50 51 52 |
# File 'lib/lyrics/lyrics.rb', line 47 def to_s() ret = " - request artist: #{@artist}\n - request title: #{@title}" ret << "\n - request album: #{@album}" if @album ret << "\n - request year: #{@year}" if @year return ret end |