Class: Anchord::Library
- Inherits:
-
Object
- Object
- Anchord::Library
- Defined in:
- lib/anchord/library.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add_chord(tuning = Anchord.tuning, &block) ⇒ Object
- #chords ⇒ Object
-
#initialize(chords = []) ⇒ Library
constructor
A new instance of Library.
Constructor Details
#initialize(chords = []) ⇒ Library
Returns a new instance of Library.
4 5 6 7 |
# File 'lib/anchord/library.rb', line 4 def initialize(chords=[]) @chords_hash = {} populate_chords_hash unless chords.empty? end |
Class Method Details
.load_from_chord_files(chord_files = Anchord.chord_files, reader = File) ⇒ Object
32 33 34 35 36 37 38 |
# 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 |
Instance Method Details
#[](key) ⇒ Object
15 16 17 |
# File 'lib/anchord/library.rb', line 15 def [](key) @chords_hash[key] end |
#add_chord(tuning = Anchord.tuning, &block) ⇒ Object
9 10 11 12 13 |
# 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 ⇒ Object
19 20 21 |
# File 'lib/anchord/library.rb', line 19 def chords @chords_hash.values end |