Class: Chordpro::Chord
- Inherits:
-
Struct
- Object
- Struct
- Chordpro::Chord
- 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
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute 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_s ⇒ Object
19 20 21 |
# File 'lib/chordpro/chord.rb', line 19 def to_s name.gsub(REGEX) { |match| SUBSTITUTIONS[match] } end |