Module: MIDIEvents::Constant::Loader::DSL Private
- Defined in:
- lib/midi-events/constant.rb
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.
DSL class methods for message classes to work with constants
These methods are extended into message classes to provide constant lookup functionality (e.g., NoteOn["C4"]).
Instance Method Summary collapse
- #constant_map ⇒ Hash private
- #constant_name ⇒ String private
- #constant_property ⇒ Symbol private
- #display_name ⇒ String private
-
#find(const_name) ⇒ MIDIEvents::Constant::MessageBuilder?
(also: #[])
private
Find a constant and return a MessageBuilder bound to it.
-
#get_constant(name) ⇒ String
private
Find a constant value in this class's group for the passed in key.
-
#type_for_status ⇒ Fixnum
private
Get the status nibble for this particular message type.
Instance Method Details
#constant_map ⇒ 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.
331 332 333 |
# File 'lib/midi-events/constant.rb', line 331 def constant_map const_get('CONSTANT') if const_defined?('CONSTANT') end |
#constant_name ⇒ String
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.
336 337 338 |
# File 'lib/midi-events/constant.rb', line 336 def constant_name constant_map&.keys&.first end |
#constant_property ⇒ Symbol
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.
341 342 343 |
# File 'lib/midi-events/constant.rb', line 341 def constant_property constant_map[constant_name] unless constant_map.nil? end |
#display_name ⇒ String
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.
326 327 328 |
# File 'lib/midi-events/constant.rb', line 326 def display_name const_get('DISPLAY_NAME') if const_defined?('DISPLAY_NAME') end |
#find(const_name) ⇒ MIDIEvents::Constant::MessageBuilder? Also known as: []
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.
Find a constant and return a MessageBuilder bound to it
This enables the bracket syntax: NoteOn["C4"].new(channel, velocity)
361 362 363 364 |
# File 'lib/midi-events/constant.rb', line 361 def find(const_name) const = get_constant(const_name.to_s) MessageBuilder.new(self, const) unless const.nil? end |
#get_constant(name) ⇒ String
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.
Find a constant value in this class's group for the passed in key
317 318 319 320 321 322 323 |
# File 'lib/midi-events/constant.rb', line 317 def get_constant(name) key = constant_name || display_name return if key.nil? group = Group[key] group.find(name) end |
#type_for_status ⇒ Fixnum
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 status nibble for this particular message type
347 348 349 |
# File 'lib/midi-events/constant.rb', line 347 def type_for_status Constant::Status[display_name] end |