Sha256: 9e40217b8439d7bb4cd750e0c2276381d44355c173da93f4b2be0757e512462b

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

module Coltrane
  module Commands
    class Command
      COMMON_OPTIONS = {
        on: [
          '--on <INSTRUMENT>',
          'Shows the notes on the given instrument/representation type. ' \
          'Can be text, piano, guitar, ukulele, bass.' \
          'You can also provide a custom guitar using the following format:' \
          '--on custom_guitar=D2-A3-D3-B3-C3'
        ],

        flavor: [
          '--flavor <FLAVOR>',
          'Chooses which additional information to display: ' \
          'marks, notes, intervals or degrees'
        ],

        voicings: [
          '--voicings <NUMBER>',
          'Number of voicings for guitar like instruments. Default is 6' \
          'provided they are separated by dashes'
        ]
      }

      def custom_guitar
        on
        .to_s
        .split('=')
        .fetch(1)
        .split('-')
        .yield_self { |tuning| Representation::Guitar.new(tuning: tuning) }
      end

      def render
        puts "\n" + Renderers::TextRenderer.render(
          representation, **renderer_options
        )
      end

      def renderer_options
        {}
      end

      class << self

        def subclasses
          @subclasses ||= []
        end

        def inherited(base)
          subclasses << base
          super(base)
        end

        def add_shared_option(option_name, mercenary_command)
          mercenary_command.option(option_name, *COMMON_OPTIONS[option_name])
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
coltrane-3.4.2 lib/coltrane/commands/command.rb
coltrane-3.4.1 lib/coltrane/commands/command.rb
coltrane-3.4.0 lib/coltrane/commands/command.rb
coltrane-3.3.3 lib/coltrane/commands/command.rb
coltrane-3.3.2 lib/coltrane/commands/command.rb
coltrane-3.3.1 lib/coltrane/commands/command.rb
coltrane-3.3.0 lib/coltrane/commands/command.rb
coltrane-3.2.0 lib/coltrane/commands/command.rb