Class: Coltrane::Commands::Notes
- Defined in:
- lib/coltrane/commands/notes.rb
Constant Summary
Constants inherited from Command
Instance Attribute Summary collapse
-
#flavor ⇒ Object
readonly
Returns the value of attribute flavor.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#on ⇒ Object
readonly
Returns the value of attribute on.
-
#preface ⇒ Object
readonly
Returns the value of attribute preface.
Class Method Summary collapse
Instance Method Summary collapse
- #custom_guitar_notes ⇒ Object
-
#initialize(notes, flavor: :notes, on: :text, preface: nil) ⇒ Notes
constructor
A new instance of Notes.
- #on_model ⇒ Object
- #renderer_options ⇒ Object
- #representation ⇒ Object
Methods inherited from Command
add_shared_option, #custom_guitar, inherited, #render, subclasses
Constructor Details
#initialize(notes, flavor: :notes, on: :text, preface: nil) ⇒ Notes
Returns a new instance of Notes.
6 7 8 9 10 11 12 |
# File 'lib/coltrane/commands/notes.rb', line 6 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 |
Instance Attribute Details
#flavor ⇒ Object (readonly)
Returns the value of attribute flavor.
4 5 6 |
# File 'lib/coltrane/commands/notes.rb', line 4 def flavor @flavor end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
4 5 6 |
# File 'lib/coltrane/commands/notes.rb', line 4 def notes @notes end |
#on ⇒ Object (readonly)
Returns the value of attribute on.
4 5 6 |
# File 'lib/coltrane/commands/notes.rb', line 4 def on @on end |
#preface ⇒ Object (readonly)
Returns the value of attribute preface.
4 5 6 |
# File 'lib/coltrane/commands/notes.rb', line 4 def preface @preface end |
Class Method Details
.mercenary_init(program) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/coltrane/commands/notes.rb', line 36 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), **| new(notes, **).render } end end |
Instance Method Details
#custom_guitar_notes ⇒ Object
32 33 34 |
# File 'lib/coltrane/commands/notes.rb', line 32 def custom_guitar_notes Representation::Guitar::NoteSet.new(notes, guitar: custom_guitar) end |
#on_model ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/coltrane/commands/notes.rb', line 22 def on_model case on.to_sym when /custom_guitar/ then custom_guitar_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 |
#renderer_options ⇒ Object
18 19 20 |
# File 'lib/coltrane/commands/notes.rb', line 18 def { flavor: flavor } end |
#representation ⇒ Object
14 15 16 |
# File 'lib/coltrane/commands/notes.rb', line 14 def representation { preface => on_model } end |