Permalink
Browse files

Refactor StemToLilypond to eliminate duplication.

  • Loading branch information...
1 parent b113637 commit cb97b264d5d46117a8077726d2c46d3d54154b46 @colomon committed May 15, 2012
Showing with 13 additions and 13 deletions.
  1. +13 −13 bin/abc2ly.pl
View
@@ -155,28 +155,28 @@ (ABC::Header $header, $out)
$element.value ~~ ABC::Duration ?? $element.value.ticks !! 0;
}
- method StemToLilypond($stem, $suffix = "") {
+ method StemPitchToLilypond($stem) {
given $stem {
when ABC::Note {
- " " ~ $.context.get-Lilypond-pitch($stem.pitch)
- ~ $.context.get-Lilypond-duration($stem)
- ~ ($stem.is-tie ?? '~' !! '')
- ~ $suffix
- ~ " ";
+ $.context.get-Lilypond-pitch($stem.pitch)
}
-
+
when ABC::Stem {
- " <" ~ $stem.notes.map({ $.context.get-Lilypond-pitch($_.pitch) }).join(' ') ~ ">"
- ~ $.context.get-Lilypond-duration($stem)
- ~ ($stem.is-tie ?? '~' !! '')
- ~ $suffix
- ~ " ";
+ "<" ~ $stem.notes.map({ $.context.get-Lilypond-pitch($_.pitch) }).join(' ') ~ ">"
}
-
+
die "Unrecognized alleged stem: " ~ $stem.perl;
}
}
+ method StemToLilypond($stem, $suffix = "") {
+ " " ~ self.StemPitchToLilypond($stem)
+ ~ $.context.get-Lilypond-duration($stem)
+ ~ ($stem.is-tie ?? '~' !! '')
+ ~ $suffix
+ ~ " ";
+ }
+
method WrapBar($lilypond-bar, $duration) {
my $ticks-in-measure = $.context.ticks-in-measure;
my $result = "";

0 comments on commit cb97b26

Please sign in to comment.