Module: MIDIMessage::Constant::Loader
Overview
Loading constants from the spec file into messages
Defined Under Namespace
Modules: DSL
Instance Method Summary collapse
-
#get_index(message) ⇒ Fixnum
Get the index of the constant from the given message’s type.
-
#get_info(message) ⇒ Hash?
Used to populate message metadata with information gathered from midi.yml.
Instance Method Details
#get_index(message) ⇒ Fixnum
Get the index of the constant from the given message’s type
179 180 181 182 |
# File 'lib/midi-message/constant.rb', line 179 def get_index() key = .class.constant_property .class.properties.index(key) || 0 end |
#get_info(message) ⇒ Hash?
Used to populate message metadata with information gathered from midi.yml
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/midi-message/constant.rb', line 187 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 |