Class: PM::SongList
- Inherits:
-
Object
- Object
- PM::SongList
- Defined in:
- lib/patchmaster/song_list.rb
Overview
A SongList is a list of Songs.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#songs ⇒ Object
Returns the value of attribute songs.
Instance Method Summary collapse
- #<<(song) ⇒ Object
-
#find(name_regex) ⇒ Object
Returns the first Song that matches
name
. -
#initialize(name) ⇒ SongList
constructor
A new instance of SongList.
Constructor Details
#initialize(name) ⇒ SongList
Returns a new instance of SongList.
8 9 10 11 |
# File 'lib/patchmaster/song_list.rb', line 8 def initialize(name) @name = name @songs = [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/patchmaster/song_list.rb', line 6 def name @name end |
#songs ⇒ Object
Returns the value of attribute songs.
6 7 8 |
# File 'lib/patchmaster/song_list.rb', line 6 def songs @songs end |
Instance Method Details
#<<(song) ⇒ Object
13 14 15 |
# File 'lib/patchmaster/song_list.rb', line 13 def <<(song) @songs << song end |
#find(name_regex) ⇒ Object
Returns the first Song that matches name
. name
may be either a Regexp or a String. The match will be made case-insensitive.
19 20 21 22 |
# File 'lib/patchmaster/song_list.rb', line 19 def find(name_regex) name_regex = Regexp.new(name_regex.to_s, true) # make case-insensitive @songs.detect { |s| s.name =~ name_regex } end |