Class: Uke::Chord

Inherits:
Object
  • Object
show all
Defined in:
lib/uke/chords.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fingersObject (readonly)

Returns the value of attribute fingers


3
4
5
# File 'lib/uke/chords.rb', line 3

def fingers
  @fingers
end

#keyObject (readonly)

Returns the value of attribute key


3
4
5
# File 'lib/uke/chords.rb', line 3

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name


3
4
5
# File 'lib/uke/chords.rb', line 3

def name
  @name
end

#positionsObject (readonly)

Returns the value of attribute positions


3
4
5
# File 'lib/uke/chords.rb', line 3

def positions
  @positions
end