Class: PM::SongList

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

Overview

A SongList is a list of Songs.

Direct Known Subclasses

SortedSongList

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/patchmaster/song_list.rb', line 6

def name
  @name
end

#songsObject

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