Top Level Namespace
Defined Under Namespace
Modules: MidiCreate
Instance Method Summary collapse
Instance Method Details
#help(msg = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/midi_create/options.rb', line 4 def help(msg = nil) printf "Error: #{msg}\n\n".yellow unless msg.nil? msg = <<~END_HELP midi_create: Creates a MIDI file containing an 8-note scale in the key of C, starting at middle C (C3 in Pro Tools and Ableton Live). Syntax: midi_create [Options] PATH_TO_MIDI_FILE Options: -b 120 Specify beats per minute (BPM); default is 120 bpm. Only integers can be used; a decimal point will cause an error. -f Overwrite the output file if present -t NAME Use this title for the track -h Show this help message END_HELP printf msg.cyan exit 1 end |
#parse_options ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/midi_create/options.rb', line 23 def = { bpm: 120, overwrite: false } OptionParser.new do |parser| parser.program_name = File.basename __FILE__ @parser = parser parser.on('-b', '--bpm BPM', OptionParser::DecimalInteger, 'Specify BPM (default is 120 bpm)') parser.on('-f', '--overwrite', 'Overwrite output MIDI file if present') parser.on('-t', '--title TITLE', 'Generate title') parser.on_tail('-h', '--help', 'Show this message') do help end end.order!(into: ) end |