class Anchord::Library
Public Class Methods
new(chords=[])
click to toggle source
# File lib/anchord/library.rb, line 4 def initialize(chords=[]) @chords_hash = {} populate_chords_hash unless chords.empty? end
Private Class Methods
load_from_chord_files(chord_files=Anchord.chord_files, reader=File)
click to toggle source
# File lib/anchord/library.rb, line 32 def load_from_chord_files(chord_files=Anchord.chord_files, reader=File) lib_instance = new chord_files.each do |chord_file| lib_instance.instance_eval(reader.read(chord_file)) end lib_instance end
Public Instance Methods
[](key)
click to toggle source
# File lib/anchord/library.rb, line 15 def [](key) @chords_hash[key] end
add_chord(tuning=Anchord.tuning, &block)
click to toggle source
# File lib/anchord/library.rb, line 9 def add_chord(tuning=Anchord.tuning, &block) chord = Chord.new(tuning, &block) @chords_hash[chord.symbol] = chord chord end
chords()
click to toggle source
# File lib/anchord/library.rb, line 19 def chords @chords_hash.values end
Private Instance Methods
populate_chords_hash()
click to toggle source
# File lib/anchord/library.rb, line 25 def populate_chords_hash chords.inject(@chords_hash) do |chords_hash, chord| chords_hash[chord.symbol] = chord end end