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
-
#[](const_name) ⇒ MIDIMessage::MessageBuilder
This returns a MessageBuilder for the class, preloaded with the selected const.
- #constant_map ⇒ Hash
- #constant_name ⇒ String
- #constant_property ⇒ Symbol
- #display_name ⇒ String
-
#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
#[](const_name) ⇒ MIDIMessage::MessageBuilder
This returns a MessageBuilder for the class, preloaded with the selected const
203 204 205 206 |
# File 'lib/midi-message/constant.rb', line 203 def [](const_name) const = get_constant(const_name.to_s) MessageBuilder.new(self, const) unless const.nil? end |
#constant_map ⇒ Hash
180 181 182 |
# File 'lib/midi-message/constant.rb', line 180 def constant_map const_get("CONSTANT") if const_defined?("CONSTANT") end |
#constant_name ⇒ String
185 186 187 |
# File 'lib/midi-message/constant.rb', line 185 def constant_name constant_map.keys.first unless constant_map.nil? end |
#constant_property ⇒ Symbol
190 191 192 |
# File 'lib/midi-message/constant.rb', line 190 def constant_property constant_map[constant_name] unless constant_map.nil? end |
#display_name ⇒ String
175 176 177 |
# File 'lib/midi-message/constant.rb', line 175 def display_name const_get("DISPLAY_NAME") if const_defined?("DISPLAY_NAME") end |
#get_constant(name) ⇒ String
Find a constant value in this class’s group for the passed in key
166 167 168 169 170 171 172 |
# File 'lib/midi-message/constant.rb', line 166 def get_constant(name) key = constant_name || display_name unless key.nil? group = Group[key] group.find(name) end end |
#type_for_status ⇒ Fixnum
Get the status nibble for this particular message type
196 197 198 |
# File 'lib/midi-message/constant.rb', line 196 def type_for_status Constant::Status[display_name] end |