Permalink
Browse files

Set title when getting an already created Fretboard

  • Loading branch information...
1 parent 776d903 commit 39f507969d3b08a783e1f7be516e5f25dd3ea369 @choan committed Mar 15, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/fretboards/fretboard_collection.rb
@@ -21,6 +21,7 @@ def add(dots, attrs = {})
def fretboard(dots, attrs = {})
if dots.is_a? Fretboard
fb = dots
+ fb.title = attrs[:title] if attrs[:title]
else
fb = Fretboard.new(@opts)
fb.terse(dots, attrs)
@@ -47,6 +48,7 @@ def renderer
def render_to_files(output_dir = '.')
# TODO stablish filenaming pattern
+ # TODO raise if not available name
@col.each do |fb|
File.open("#{output_dir}/#{fb.title.gsub(/[^A-z0-9]/, "_")}.svg", "w") { |f| f.puts(renderer.render(fb)) }
end

0 comments on commit 39f5079

Please sign in to comment.