Class: Uke::Fretboard

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(chord, style = nil) ⇒ Fretboard

Returns a new instance of Fretboard.

Raises:

  • (ArgumentError)


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

#linesObject



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