Class: KargWare::Song
- Inherits:
-
Object
- Object
- KargWare::Song
- Defined in:
- lib/Song.rb
Overview
A class Song for music
Instance Attribute Summary collapse
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #echo ⇒ Object
-
#initialize(name, artist, duration) ⇒ Song
constructor
attr_reader :name, :artist.
- #to_s ⇒ Object
Constructor Details
#initialize(name, artist, duration) ⇒ Song
attr_reader :name, :artist
10 11 12 13 14 |
# File 'lib/Song.rb', line 10 def initialize(name, artist, duration) @name = name @artist = artist @duration = duration end |
Instance Attribute Details
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
6 7 8 |
# File 'lib/Song.rb', line 6 def artist @artist end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/Song.rb', line 6 def duration @duration end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/Song.rb', line 6 def name @name end |
Instance Method Details
#echo ⇒ Object
21 22 23 |
# File 'lib/Song.rb', line 21 def echo puts to_s end |
#to_s ⇒ Object
16 17 18 19 |
# File 'lib/Song.rb', line 16 def to_s # format('%s (%s) [ %s ]', @name, @artist, @duration) "#{@name} (#{@artist}) [ #{@duration} ]" end |