Class: Coltrane::Cli::Representation
- Inherits:
-
Object
- Object
- Coltrane::Cli::Representation
- Defined in:
- lib/cli/representation.rb
Overview
It manages notes representations, most of times instruments
Constant Summary collapse
- ACCEPTED_FLAVORS =
i[marks notes intervals degrees].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #hint ⇒ Object
-
#initialize(notes, flavor) ⇒ Representation
constructor
A new instance of Representation.
Constructor Details
#initialize(notes, flavor) ⇒ Representation
Returns a new instance of Representation.
26 27 28 29 30 |
# File 'lib/cli/representation.rb', line 26 def initialize(notes, flavor) @notes = notes @flavor = flavor @ref_note = notes.first end |
Class Method Details
.build(type, notes, flavor) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cli/representation.rb', line 14 def self.build(type, notes, flavor) raise WrongFlavorError unless ACCEPTED_FLAVORS.include?(flavor) type = case type when :ukelele then :ukulele when :bass then :bass_guitar else type end raise(WrongRepresentationTypeError, type) unless @@types.include?(type) @@types[type].new(notes, flavor) end |
.inherited(subclass) ⇒ Object
9 10 11 12 |
# File 'lib/cli/representation.rb', line 9 def self.inherited(subclass) @@types ||= {} @@types[subclass.to_s.split('::').last.underscore.to_sym] = subclass end |
Instance Method Details
#hint ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cli/representation.rb', line 32 def hint case @flavor when :marks then '' # when :notes then "(\u266E means the note is natural, not flat nor sharp)" when :intervals " The letters represent the intervals relative to the root tone\n Ex: 1P = Perfect First / 3m = Minor Third / 4A = Augmented Fourth\n DESC\n\n when :degrees then '(The numbers represent the degree of the note in the scale)'\n end\nend\n" |