Module: MIDIEvents::Constant::Loader::DSL
- Defined in:
- lib/midi-events/constant.rb
Overview
DSL type class methods for loading constants into messages
Instance Method Summary collapse
- #constant_map ⇒ Hash
- #constant_name ⇒ String
- #constant_property ⇒ Symbol
- #display_name ⇒ String
-
#find(const_name) ⇒ MIDIEvents::MessageBuilder
(also: #[])
This returns a MessageBuilder for the class, preloaded with the selected const.
-
#get_constant(name) ⇒ String
Find a constant value in this class’s group for the passed in key.
-
#type_for_status ⇒ Fixnum
Get the status nibble for this particular message type.
Instance Method Details
#constant_map ⇒ Hash
211 212 213 |
# File 'lib/midi-events/constant.rb', line 211 def constant_map const_get('CONSTANT') if const_defined?('CONSTANT') end |
#constant_name ⇒ String
216 217 218 |
# File 'lib/midi-events/constant.rb', line 216 def constant_name constant_map&.keys&.first end |
#constant_property ⇒ Symbol
221 222 223 |
# File 'lib/midi-events/constant.rb', line 221 def constant_property constant_map[constant_name] unless constant_map.nil? end |
#display_name ⇒ String
206 207 208 |
# File 'lib/midi-events/constant.rb', line 206 def display_name const_get('DISPLAY_NAME') if const_defined?('DISPLAY_NAME') end |
#find(const_name) ⇒ MIDIEvents::MessageBuilder Also known as: []
This returns a MessageBuilder for the class, preloaded with the selected const
234 235 236 237 |
# File 'lib/midi-events/constant.rb', line 234 def find(const_name) const = get_constant(const_name.to_s) MessageBuilder.new(self, const) unless const.nil? end |
#get_constant(name) ⇒ String
Find a constant value in this class’s group for the passed in key
197 198 199 200 201 202 203 |
# File 'lib/midi-events/constant.rb', line 197 def get_constant(name) key = constant_name || display_name return if key.nil? group = Group[key] group.find(name) end |
#type_for_status ⇒ Fixnum
Get the status nibble for this particular message type
227 228 229 |
# File 'lib/midi-events/constant.rb', line 227 def type_for_status Constant::Status[display_name] end |