Sha256: f4c27cf99c8c29c9cad9280db8392a072fd303575ff25b375b9d0e0df785841b
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
module Coltrane module Commands class Scale < Command def representation return on_model if on == :text { preface => on_model } end def self.parse(scale_notation) scale_notation .split(' ', 2) .yield_self { |(tone, scale_name)| Theory::Scale.fetch(scale_name.gsub(' ', '_'), tone) } end def self.mercenary_init(program) program.command(:scale) do |c| c.syntax 'scale <root_note> <scale name> [--on <instrument>]' c.description 'Gives you information about a scale. Ex: coltrane scale D Natural Minor --on guitar' c.option :tertians, '--tertians SIZE', 'Outputs all tertian chords from the given size from the scale' c.option :chords, '--chords [SIZE]', 'Outputs all chords from given size from the scale. Leave size empty to retrieve all' add_shared_option(:flavor, c) add_shared_option(:on, c) c.action { |scale_notation, **options| parse(scale_notation.join(' ')) .yield_self { |scale| if options[:tertians] scale .tertians(options[:tertians].to_i) .each { |chord| Commands::Chords.new(chord, **options).render } elsif options[:chords] scale.chords(options[:chords].to_i) .each { |chord| Commands::Chords.new(chord, **options).render } else scale.notes .yield_self {|notes| Commands::Notes.new(notes, **options.merge(preface: scale.full_name)).render } end } } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coltrane-3.0.0.rc1 | lib/coltrane/commands/scale.rb |
coltrane-3.0.0.pre | lib/coltrane/commands/scale.rb |