Class: WTFChord::Formatters::Piano1
- Inherits:
-
Object
- Object
- WTFChord::Formatters::Piano1
- Defined in:
- lib/wtf_chord/formatters/piano1.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pressed_keys ⇒ Object
readonly
Returns the value of attribute pressed_keys.
Class Method Summary collapse
Instance Method Summary collapse
- #actual_notes ⇒ Object
- #draw ⇒ Object
-
#initialize(keys) ⇒ Piano1
constructor
A new instance of Piano1.
- #keyboard_presentation ⇒ Object
- #unique_notes ⇒ Object
Constructor Details
#initialize(keys) ⇒ Piano1
22 23 24 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 22 def initialize(keys) @pressed_keys = keys end |
Instance Attribute Details
#pressed_keys ⇒ Object (readonly)
Returns the value of attribute pressed_keys.
20 21 22 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 20 def pressed_keys @pressed_keys end |
Class Method Details
.separator ⇒ Object
8 9 10 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 8 def self.separator "\n" end |
.to_proc ⇒ Object
12 13 14 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 12 def self.to_proc proc { |keys| new(keys).draw } end |
.with_rates {|_self| ... } ⇒ Object
16 17 18 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 16 def self.with_rates(*) yield(self) end |
Instance Method Details
#actual_notes ⇒ Object
33 34 35 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 33 def actual_notes actual_strings.map(&:note) end |
#draw ⇒ Object
26 27 28 29 30 31 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 26 def draw [ unique_notes.sort.join(" - "), keyboard_presentation ].join("\n\n") end |
#keyboard_presentation ⇒ Object
41 42 43 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 41 def keyboard_presentation KeyboardPresentation.press(*unique_notes.map(&:position)) end |
#unique_notes ⇒ Object
37 38 39 |
# File 'lib/wtf_chord/formatters/piano1.rb', line 37 def unique_notes actual_notes.uniq(&:position) end |