Class: Fretboard::Tunings
- Inherits:
-
Object
- Object
- Fretboard::Tunings
- Defined in:
- lib/fretboard/tunings.rb
Overview
rubocop:disable Metrics/ClassLength
Class Method Summary collapse
-
.draw_list ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
- .exists?(tuning_name) ⇒ Boolean
- .fetch(tuning_name) ⇒ Object
- .list ⇒ Object
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #fetch ⇒ Object
-
#initialize(tuning_name) ⇒ Tunings
constructor
A new instance of Tunings.
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_list ⇒ Object
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
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 |
.list ⇒ Object
309 310 311 |
# File 'lib/fretboard/tunings.rb', line 309 def self.list TUNINGS end |
Instance Method Details
#exists? ⇒ Boolean
357 358 359 |
# File 'lib/fretboard/tunings.rb', line 357 def exists? TUNINGS.key?(@tuning_name) end |
#fetch ⇒ Object
353 354 355 |
# File 'lib/fretboard/tunings.rb', line 353 def fetch TUNINGS[@tuning_name] end |