Class: Uke::Chord
- Inherits:
-
Object
- Object
- Uke::Chord
- Defined in:
- lib/uke/chords.rb
Instance Attribute Summary collapse
-
#fingers ⇒ Object
readonly
Returns the value of attribute fingers.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#positions ⇒ Object
readonly
Returns the value of attribute positions.
Instance Method Summary collapse
-
#initialize(line) ⇒ Chord
constructor
A new instance of Chord.
Constructor Details
#initialize(line) ⇒ Chord
Returns a new instance of Chord.
5 6 7 8 9 10 11 12 |
# File 'lib/uke/chords.rb', line 5 def initialize(line) parts = line.split(/\s{2,}/).map { |part| part.split(',') } @name = parts[0].join.tr(' ', '') @key = @name[0...2] @positions = parts[1].map(&:to_i) @fingers = parts[2] && parts[2].map(&:to_i) end |
Instance Attribute Details
#fingers ⇒ Object (readonly)
Returns the value of attribute fingers.
3 4 5 |
# File 'lib/uke/chords.rb', line 3 def fingers @fingers end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/uke/chords.rb', line 3 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/uke/chords.rb', line 3 def name @name end |
#positions ⇒ Object (readonly)
Returns the value of attribute positions.
3 4 5 |
# File 'lib/uke/chords.rb', line 3 def positions @positions end |