Module: MIDIMessage::Constant::Loader::DSL
- Defined in:
- lib/midi-message/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) ⇒ MIDIMessage::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
225 226 227 |
# File 'lib/midi-message/constant.rb', line 225 def constant_map const_get("CONSTANT") if const_defined?("CONSTANT") end |
#constant_name ⇒ String
230 231 232 |
# File 'lib/midi-message/constant.rb', line 230 def constant_name constant_map.keys.first unless constant_map.nil? end |
#constant_property ⇒ Symbol
235 236 237 |
# File 'lib/midi-message/constant.rb', line 235 def constant_property constant_map[constant_name] unless constant_map.nil? end |
#display_name ⇒ String
220 221 222 |
# File 'lib/midi-message/constant.rb', line 220 def display_name const_get("DISPLAY_NAME") if const_defined?("DISPLAY_NAME") end |
#find(const_name) ⇒ MIDIMessage::MessageBuilder Also known as: []
This returns a MessageBuilder for the class, preloaded with the selected const
248 249 250 251 |
# File 'lib/midi-message/constant.rb', line 248 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
211 212 213 214 215 216 217 |
# File 'lib/midi-message/constant.rb', line 211 def get_constant(name) key = constant_name || display_name unless key.nil? group = Group[key] group.find(name) end end |