Class: MIDIMessage::Constant::Group
- Inherits:
-
Object
- Object
- MIDIMessage::Constant::Group
- Defined in:
- lib/midi-message/constant.rb
Overview
MIDI Constant container
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.[](key) ⇒ ConstantGroup
Find a constant group by its key.
-
.all ⇒ Array<ConstantGroup>
All constant groups.
Instance Method Summary collapse
-
#find(name) ⇒ Constant::Map
(also: #[])
Find a constant by its name.
-
#find_by_value(value) ⇒ Constant::Map
Find a constant by its value.
-
#initialize(key, constants) ⇒ Group
constructor
A new instance of Group.
Constructor Details
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
15 16 17 |
# File 'lib/midi-message/constant.rb', line 15 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
15 16 17 |
# File 'lib/midi-message/constant.rb', line 15 def value @value end |
Class Method Details
.[](key) ⇒ ConstantGroup
Find a constant group by its key
47 48 49 50 |
# File 'lib/midi-message/constant.rb', line 47 def self.[](key) ensure_initialized @groups.find { |g| g.key.to_s.downcase == key.to_s.downcase } end |
.all ⇒ Array<ConstantGroup>
All constant groups
39 40 41 42 |
# File 'lib/midi-message/constant.rb', line 39 def self.all ensure_initialized @groups end |
Instance Method Details
#find(name) ⇒ Constant::Map Also known as: []
Find a constant by its name
25 26 27 |
# File 'lib/midi-message/constant.rb', line 25 def find(name) @constants.find { |const| const.key.to_s.downcase == name.to_s.downcase } end |
#find_by_value(value) ⇒ Constant::Map
Find a constant by its value
33 34 35 |
# File 'lib/midi-message/constant.rb', line 33 def find_by_value(value) @constants.find { |const| const.value.to_s.downcase == value.to_s.downcase } end |