Class: Uke::Fretboard
- Inherits:
-
Object
- Object
- Uke::Fretboard
- Defined in:
- lib/uke/fretboard.rb
Constant Summary collapse
- STYLES =
{ small: { open: " ∘", finger: " •" }, medium: { open: " ⚪", finger: " ⚫"}, large: { open: " ◯", finger: " " }, fingering: {open: " ◯", finger: [" ➊", " ➋", " ➌", " ➍"]} }
Instance Method Summary collapse
-
#initialize(chord, style = nil) ⇒ Fretboard
constructor
A new instance of Fretboard.
- #lines ⇒ Object
Constructor Details
#initialize(chord, style = nil) ⇒ Fretboard
Returns a new instance of Fretboard.
10 11 12 13 14 15 |
# File 'lib/uke/fretboard.rb', line 10 def initialize(chord, style = nil) @chord = chord @style = style.to_sym raise ArgumentError, 'Unknown style' unless STYLES[@style] @config = chord_to_config(@chord) end |
Instance Method Details
#lines ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/uke/fretboard.rb', line 17 def lines (TEMPLATE % @config).split($/).map do |line| matches = line.match(/(([➊➋➌➍]\s{2,})+[^│])/) if matches part = matches.captures.first line.gsub(part, part.gsub(/\s{2}/, ' ')) else line end end end |