Class: Kadryll::Drill
- Inherits:
-
Object
- Object
- Kadryll::Drill
- Defined in:
- lib/kadryll/drill.rb
Instance Attribute Summary collapse
-
#left_foot ⇒ Object
Returns the value of attribute left_foot.
-
#left_hand ⇒ Object
Returns the value of attribute left_hand.
-
#name ⇒ Object
Returns the value of attribute name.
-
#right_foot ⇒ Object
Returns the value of attribute right_foot.
-
#right_hand ⇒ Object
Returns the value of attribute right_hand.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
- .from_string(template, options = {}) ⇒ Object
- .lilypond_file(name) ⇒ Object
- .parse(template, options = {}) ⇒ Object
Instance Method Summary collapse
- #command ⇒ Object
- #generate_png ⇒ Object
-
#initialize(name, time, measures, options = {}) ⇒ Drill
constructor
A new instance of Drill.
- #lilypond_file ⇒ Object
- #output_to ⇒ Object
- #template ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(name, time, measures, options = {}) ⇒ Drill
Returns a new instance of Drill.
23 24 25 26 27 |
# File 'lib/kadryll/drill.rb', line 23 def initialize(name, time, measures, = {}) self.name = build_name(name, [:prefix]) self.time = time self.right_hand, self.left_hand, self.right_foot, self.left_foot = measures end |
Instance Attribute Details
#left_foot ⇒ Object
Returns the value of attribute left_foot.
22 23 24 |
# File 'lib/kadryll/drill.rb', line 22 def left_foot @left_foot end |
#left_hand ⇒ Object
Returns the value of attribute left_hand.
22 23 24 |
# File 'lib/kadryll/drill.rb', line 22 def left_hand @left_hand end |
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/kadryll/drill.rb', line 22 def name @name end |
#right_foot ⇒ Object
Returns the value of attribute right_foot.
22 23 24 |
# File 'lib/kadryll/drill.rb', line 22 def right_foot @right_foot end |
#right_hand ⇒ Object
Returns the value of attribute right_hand.
22 23 24 |
# File 'lib/kadryll/drill.rb', line 22 def right_hand @right_hand end |
#time ⇒ Object
Returns the value of attribute time.
22 23 24 |
# File 'lib/kadryll/drill.rb', line 22 def time @time end |
Class Method Details
.from_string(template, options = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/kadryll/drill.rb', line 9 def from_string(template, = {}) drill = parse template, drill.write drill end |
.lilypond_file(name) ⇒ Object
5 6 7 |
# File 'lib/kadryll/drill.rb', line 5 def lilypond_file(name) "#{Kadryll.input_dir}#{name}.ly" end |
.parse(template, options = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/kadryll/drill.rb', line 15 def parse(template, = {}) data, *measures = template.split("\n").map(&:strip) name, time = data.split(" ") new(name, time, measures, ) end |
Instance Method Details
#command ⇒ Object
29 30 31 |
# File 'lib/kadryll/drill.rb', line 29 def command "lilypond --png --output=#{output_to} #{lilypond_file}" end |
#generate_png ⇒ Object
33 34 35 36 |
# File 'lib/kadryll/drill.rb', line 33 def generate_png system(command) "#{output_to}.png" end |
#lilypond_file ⇒ Object
49 50 51 |
# File 'lib/kadryll/drill.rb', line 49 def lilypond_file Drill.lilypond_file(name) end |
#output_to ⇒ Object
38 39 40 |
# File 'lib/kadryll/drill.rb', line 38 def output_to "#{Kadryll.output_dir}#{name}" end |
#template ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/kadryll/drill.rb', line 53 def template <<-DRILL.gsub(/^\ {6}/, '') \\version "2.14.2" \\header { tagline = \\markup { \\fill-line { \\line { \\null } \\line { \\null } \\line { \\tiny \\with-color #(x11-color 'gray80) { #{Kadryll.copyright} \\char ##x00A9 } } } } } #(set! paper-alist (cons '("drill" . (cons (* 190 mm) (* 80 mm))) paper-alist)) \\paper { #(set-paper-size "drill") #(define top-margin (* 7 mm)) #(define line-width (* 140 mm)) } signature = \\time #{time} rh = \\drummode { #{right_hand} } lh = \\drummode { #{left_hand} } rf = \\drummode { #{right_foot} } lf = \\drummode { #{left_foot} } #(define quake '((tamtam default #t 0))) quakestaff = { \\override DrumStaff.StaffSymbol #'line-positions = #'( 0 ) \\override DrumStaff.BarLine #'bar-extent = #'(-1 . 1.5) \\override DrumStaff.InstrumentName #'self-alignment-X = #LEFT \\set DrumStaff.drumStyleTable = #(alist->hash-table quake) \\set fontSize = #-2 \\signature \\override DrumStaff.Rest #'staff-position = #0 } << \\new DrumStaff { \\quakestaff \\set DrumStaff.instrumentName = "Right Hand " \\override Stem #'direction = #UP \\rh | \\rh | \\rh | \\rh | } \\new DrumStaff { \\quakestaff \\set DrumStaff.instrumentName = \\markup \\left-column { "Left Hand " } \\override Stem #'direction = #DOWN \\lh | \\lh | \\lh | \\lh | } \\new DrumStaff { \\quakestaff \\set DrumStaff.instrumentName = \\markup \\left-column { "Right Foot " } \\override Stem #'direction = #UP \\rf | \\rf | \\rf | \\rf | } \\new DrumStaff { \\quakestaff \\set DrumStaff.instrumentName = \\markup \\left-column { "Left Foot " } \\override Stem #'direction = #DOWN \\lf | \\lf | \\lf | \\lf | } >> DRILL end |
#write ⇒ Object
42 43 44 45 46 47 |
# File 'lib/kadryll/drill.rb', line 42 def write Kadryll.initialize File.open(lilypond_file, 'w') do |file| file.write template end end |