Class: Fretboard::Tunings

Inherits:
Object
  • Object
show all
Defined in:
lib/fretboard/tunings.rb

Overview

rubocop:disable Metrics/ClassLength

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tuning_name) ⇒ Tunings

Returns a new instance of Tunings.



349
350
351
# File 'lib/fretboard/tunings.rb', line 349

def initialize(tuning_name)
  @tuning_name = tuning_name.upcase.to_sym
end

Class Method Details

.draw_listObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/fretboard/tunings.rb', line 313

def self.draw_list # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  headings = []
  rows = []

  headings << "Tuning"
  headings << "Notes"

  list.each do |tuning_code, tuning_data|
    row = []

    row << tuning_code

    prepared_string_notes = tuning_data[:STRINGS].map do |_string_number, string_notes|
      note = string_notes[:NOTE]

      note.is_a?(Array) ? note.join("/") : note
    end.join(", ")

    row << prepared_string_notes

    rows << row
  end

  Fretboard::Console.print_table(headings.uniq, rows)

  nil
end

.exists?(tuning_name) ⇒ Boolean

Returns:

  • (Boolean)


345
346
347
# File 'lib/fretboard/tunings.rb', line 345

def self.exists?(tuning_name)
  new(tuning_name).exists?
end

.fetch(tuning_name) ⇒ Object



341
342
343
# File 'lib/fretboard/tunings.rb', line 341

def self.fetch(tuning_name)
  new(tuning_name).fetch
end

.listObject



309
310
311
# File 'lib/fretboard/tunings.rb', line 309

def self.list
  TUNINGS
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


357
358
359
# File 'lib/fretboard/tunings.rb', line 357

def exists?
  TUNINGS.key?(@tuning_name)
end

#fetchObject



353
354
355
# File 'lib/fretboard/tunings.rb', line 353

def fetch
  TUNINGS[@tuning_name]
end