class HeadMusic::Solmization
A scale degree is a number indicating the ordinality of the spelling in the key signature. TODO: Rewrite to accept a tonal_center and a scale type.
Constants
- DEFAULT_SOLMIZATION
- RECORDS
Attributes
syllables[R]
Public Class Methods
get(identifier = nil)
click to toggle source
# File lib/head_music/solmization.rb, line 14 def self.get(identifier = nil) get_by_name(identifier) end
new(name = nil)
click to toggle source
# File lib/head_music/solmization.rb, line 22 def initialize(name = nil) name = nil if name.empty? name ||= DEFAULT_SOLMIZATION record = record_for_name(name) if record initialize_data_from_record(record) else self.name = name end end
Private Instance Methods
initialize_data_from_record(record)
click to toggle source
# File lib/head_music/solmization.rb, line 42 def initialize_data_from_record(record) @syllables = record[:syllables] initialize_localized_names(record[:localized_names]) end
initialize_localized_names(list)
click to toggle source
# File lib/head_music/solmization.rb, line 47 def initialize_localized_names(list) @localized_names = (list || []).map do |name_attributes| HeadMusic::Named::LocalizedName.new(name_attributes.slice(:name, :locale_code, :abbreviation)) end end
record_for_name(name)
click to toggle source
# File lib/head_music/solmization.rb, line 33 def record_for_name(name) key = HeadMusic::Utilities::HashKey.for(name) RECORDS.detect do |record| name_strings = record[:localized_names].map { |localized_name| localized_name[:name] } name_keys = name_strings.map { |name_string| HeadMusic::Utilities::HashKey.for(name_string) } name_keys.include?(key) end end