Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 28 lines (23 sloc) 0.729 kb
23bdd44 @colomon Start to sketch in ABC::Duration.
authored
1 use v6;
2
3 role ABC::Duration {
4 has $.ticks;
1c1e94d @colomon Start to sketch in ABC::Duration and ABC::Note.
authored
5
6 our multi sub duration-from-parse($top) is export {
7 ABC::Duration.new(:ticks($top.Int || 1));
8 }
23bdd44 @colomon Start to sketch in ABC::Duration.
authored
9
1c1e94d @colomon Start to sketch in ABC::Duration and ABC::Note.
authored
10 our multi sub duration-from-parse($top, $bottom) is export {
11 if +($top // 0) == 0 && +($bottom // 0) == 0 {
23bdd44 @colomon Start to sketch in ABC::Duration.
authored
12 ABC::Duration.new(:ticks(1/2));
13 } else {
14 ABC::Duration.new(:ticks(($top.Int || 1) / ($bottom.Int || 1)));
15 }
16 }
17
1c1e94d @colomon Start to sketch in ABC::Duration and ABC::Note.
authored
18 our method Str() {
19 given $.ticks {
20 when 1 { "---"; } # for debugging, should be ""
21 when 1/2 { "/"; }
22 when Int { .Str; }
23 when Rat { .perl; }
24 die "Duration must be Int or Rat, but it's { .WHAT }";
25 }
26 }
23bdd44 @colomon Start to sketch in ABC::Duration.
authored
27 }
Something went wrong with that request. Please try again.