GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: A simple chord viewing interface layered upon pngs of mandolin chords I found somewhere a while ago.
Clone URL: git://github.com/kjell/chords.git
simple find method works on strings and regexen
kjell (author)
Sat Aug 09 19:02:35 -0700 2008
commit  9b7663ee01d496bb08815add3d5c5206838be583
tree    cde02daae0c551682c9f81bef740e22149aab036
parent  e2e78047078030cff6d3db29a8c3fed2c9a945a2
...
14
15
16
 
 
 
 
 
 
 
 
 
17
18
19
20
21
22
23
 
24
25
26
...
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
32
33
34
35
0
@@ -14,12 +14,21 @@ def group(chords)
0
   chords.group_by{|struct| struct.chord.first}
0
 end
0
 
0
+def find(chord)
0
+ chords.select do |c|
0
+ case chord
0
+ when Regexp then c.chord.gsub(/\s|-|_/, '') =~ chord
0
+ when String then c.chord == chord
0
+ end
0
+ end
0
+end
0
+
0
 get('/') do
0
   @chords = group(chords)
0
   haml :chords
0
 end
0
 
0
 get('/find') do
0
- @chords = group(chords.select {|c| c.chord.gsub(/\s|-|_/, '') =~ /#{params[:q]}/i})
0
+ @chords = group(find(/#{params[:q]}/))
0
   haml :chords
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.