Sha256: 86769be2d55065dcd7a702ac4b22db0512b1e08edc2214c53c1f3fd20bde7850
Contents?: true
Size: 1.45 KB
Versions: 5
Compression:
Stored size: 1.45 KB
Contents
module Coltrane module Commands class Notes < Command attr_reader :notes, :flavor, :on, :preface def initialize(notes, flavor: :notes, on: :text, preface: nil) raise 'Provide some notes. Ex: coltrane notes C-D-Gb' if notes.nil? @notes = notes.is_a?(Theory::NoteSet) ? notes : Theory::NoteSet[*notes.split('-')] @flavor = flavor.to_sym @preface = preface || 'Here are the notes you asked for' @on = on end def representation { preface => on_model } end def renderer_options { flavor: flavor } end def on_model case on.to_sym when :text then notes when :guitar then Representation::Guitar.find_notes(notes) when :ukulele, :ukelele then Representation::Ukulele.find_notes(notes) when :bass then Representation::Bass.find_notes(notes) when :piano then Representation::Piano.find_notes(notes) end end def self.mercenary_init(program) program.command(:notes) do |c| c.alias(:note) c.syntax 'notes <notes separated by space> [--on <instrument>]' c.description 'Shows the given notes.' add_shared_option(:voicings, c) add_shared_option(:flavor, c) add_shared_option(:on, c) c.action { |(notes), **options| new(notes, **options).render } end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems