Module: MIDIEvents::Constant::Loader Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Internal system for loading constants into message objects
Handles the automatic population of message metadata (names, verbose names) based on constant definitions in midi.yml.
Defined Under Namespace
Modules: DSL
Class Method Summary collapse
-
.get_index(message) ⇒ Integer
private
Get the property index for a constant in a message.
-
.get_info(message) ⇒ Hash?
private
Populate message metadata using constant information from midi.yml.
Instance Method Summary collapse
-
#get_index(message) ⇒ Integer
private
Get the property index for a constant in a message.
-
#get_info(message) ⇒ Hash?
private
Populate message metadata using constant information from midi.yml.
Class Method Details
.get_index(message) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the property index for a constant in a message
277 278 279 280 |
# File 'lib/midi-events/constant.rb', line 277 def get_index() key = .class.constant_property .class.properties.index(key) || 0 end |
.get_info(message) ⇒ Hash?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Populate message metadata using constant information from midi.yml
Looks up the constant for a message and returns metadata including the constant object, name, and verbose name.
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/midi-events/constant.rb', line 289 def get_info() const_group_name = .class.display_name group_name_alias = .class.constant_name property = .class.constant_property value = .send(property) unless property.nil? value ||= .status[1] # default property to use for constants group = Constant::Group[group_name_alias] || Constant::Group[const_group_name] unless group.nil? unless (const = group.find_by_value(value)).nil? { const: const, name: const.key, verbose_name: "#{.class.display_name}: #{const.key}" } end end end |
Instance Method Details
#get_index(message) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the property index for a constant in a message
277 278 279 280 |
# File 'lib/midi-events/constant.rb', line 277 def get_index() key = .class.constant_property .class.properties.index(key) || 0 end |
#get_info(message) ⇒ Hash?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Populate message metadata using constant information from midi.yml
Looks up the constant for a message and returns metadata including the constant object, name, and verbose name.
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/midi-events/constant.rb', line 289 def get_info() const_group_name = .class.display_name group_name_alias = .class.constant_name property = .class.constant_property value = .send(property) unless property.nil? value ||= .status[1] # default property to use for constants group = Constant::Group[group_name_alias] || Constant::Group[const_group_name] unless group.nil? unless (const = group.find_by_value(value)).nil? { const: const, name: const.key, verbose_name: "#{.class.display_name}: #{const.key}" } end end end |