Module: MIDIEvents::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
166 167 168 169 |
# File 'lib/midi-events/constant.rb', line 166 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
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/midi-events/constant.rb', line 174 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: "#{message.class.display_name}: #{const.key}" } end end end |