Class: Chordpro::Chord

Inherits:
Struct
  • Object
show all
Defined in:
lib/chordpro/chord.rb

Constant Summary collapse

SUBSTITUTIONS =
{
  "b" => "",
  "#" => "",
  "aug" => "+",
  "dim" => "°",
  "2" => "²",
  "4" => "",
  "5" => "",
  "6" => "",
  "7" => "",
  "9" => "",
  "sus" => "ˢᵘˢ"
}
REGEX =
/(#{SUBSTITUTIONS.keys.join('|')})/

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/chordpro/chord.rb', line 2

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object



23
24
25
# File 'lib/chordpro/chord.rb', line 23

def accept(visitor)
  visitor.respond_to?(:chord) ? visitor.chord(self) : self
end

#to_sObject



19
20
21
# File 'lib/chordpro/chord.rb', line 19

def to_s
  name.gsub(REGEX) { |match| SUBSTITUTIONS[match] }
end