Class: Stringed::Instrument
- Inherits:
-
Object
- Object
- Stringed::Instrument
- Defined in:
- lib/stringed/instrument.rb
Instance Attribute Summary collapse
-
#fret_count ⇒ Object
Returns the value of attribute fret_count.
-
#strings ⇒ Object
Returns the value of attribute strings.
Instance Method Summary collapse
- #find(note) ⇒ Object
- #find_chord(chord) ⇒ Object
- #in_range?(fret_no) ⇒ Boolean
-
#initialize(strings, options = {}) ⇒ Instrument
constructor
A new instance of Instrument.
- #to(format, options = {}) ⇒ Object
Constructor Details
#initialize(strings, options = {}) ⇒ Instrument
Returns a new instance of Instrument.
7 8 9 10 |
# File 'lib/stringed/instrument.rb', line 7 def initialize(strings,={}) @strings = strings.map{ |string| InstrumentString.new(string.to_s, )} @fret_count = .fetch(:fret_count,14) end |
Instance Attribute Details
#fret_count ⇒ Object
Returns the value of attribute fret_count.
5 6 7 |
# File 'lib/stringed/instrument.rb', line 5 def fret_count @fret_count end |
#strings ⇒ Object
Returns the value of attribute strings.
5 6 7 |
# File 'lib/stringed/instrument.rb', line 5 def strings @strings end |
Instance Method Details
#find(note) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/stringed/instrument.rb', line 12 def find(note) matches = [] strings.each do |string| matches << string.find(note) end matches end |
#find_chord(chord) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/stringed/instrument.rb', line 20 def find_chord(chord) matches = [] strings.each do |string| matches << string.find_chord(chord) end matches end |
#in_range?(fret_no) ⇒ Boolean
28 29 30 |
# File 'lib/stringed/instrument.rb', line 28 def in_range?(fret_no) fret_no >= 0 and fret_no <= fret_count end |
#to(format, options = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/stringed/instrument.rb', line 32 def to(format,={}) require "stringed/formatters" if format == :ascii then Formatters::ASCIIInstrument.new(self,) end end |