Class: Stringed::Formatters::ASCIIInstrument
- Inherits:
-
Object
- Object
- Stringed::Formatters::ASCIIInstrument
- Includes:
- ASCII
- Defined in:
- lib/stringed/formatters.rb
Instance Method Summary collapse
- #fret_numbers ⇒ Object
-
#initialize(instrument, options = {}) ⇒ ASCIIInstrument
constructor
A new instance of ASCIIInstrument.
- #to_s ⇒ Object
Methods included from ASCII
Constructor Details
#initialize(instrument, options = {}) ⇒ ASCIIInstrument
Returns a new instance of ASCIIInstrument.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/stringed/formatters.rb', line 44 def initialize(instrument, ={}) @selected_frets = .fetch(:selected_frets,[]) @output = "" @instrument = instrument @instrument.strings.each_with_index do |string,i| selected_frets = @selected_frets[i] ? @selected_frets[i] : [] @output << string.to(:ascii,selected_frets: selected_frets ).to_s end @output << fret_numbers if .fetch(:numbered_frets,true) end |
Instance Method Details
#fret_numbers ⇒ Object
55 56 57 |
# File 'lib/stringed/formatters.rb', line 55 def fret_numbers ASCII.fret_numbers(@instrument.strings[@instrument.strings.map{|i| i.to_s.length}.each_with_index.max[1]]) end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/stringed/formatters.rb', line 59 def to_s @output end |