class Anchord::Chord

Attributes

tuning[RW]

Public Class Methods

new(tuning, &block) click to toggle source
# File lib/anchord/chord.rb, line 6
def initialize(tuning, &block)
  instance_eval(&block)
  @tuning = tuning
  @symbol = name.to_sym unless @symbol
  define_strings
end

Public Instance Methods

coordinates(val=nil) click to toggle source
# File lib/anchord/chord.rb, line 21
def coordinates(val=nil)
  @coordinates ||= val
end
name(val=nil) click to toggle source
# File lib/anchord/chord.rb, line 13
def name(val=nil)
  @name ||= val
end
symbol(val=nil) click to toggle source
# File lib/anchord/chord.rb, line 17
def symbol(val=nil)
  @symbol ||= val
end

Private Instance Methods

define_strings() click to toggle source
# File lib/anchord/chord.rb, line 27
def define_strings
  Anchord.tuning.each_with_index do |tune, position|
    method_name = "#{tune}_string".to_sym
    Chord.send(:define_method, method_name) do
      @coordinates[position]
    end
    Chord.send(:alias_method, "play_#{tune}".to_sym,method_name)
  end
end