Class: Lyrics::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#albumObject (readonly)

Returns the value of attribute album.



35
36
37
# File 'lib/lyrics/lyrics.rb', line 35

def album
  @album
end

#artistObject (readonly)

Returns the value of attribute artist.



35
36
37
# File 'lib/lyrics/lyrics.rb', line 35

def artist
  @artist
end

#fetch_dataObject

Returns the value of attribute fetch_data.



35
36
37
# File 'lib/lyrics/lyrics.rb', line 35

def fetch_data
  @fetch_data
end

#titleObject (readonly)

Returns the value of attribute title.



35
36
37
# File 'lib/lyrics/lyrics.rb', line 35

def title
  @title
end

#yearObject (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_sObject



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