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
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
-
.all ⇒ Array<ConstantGroup>
All constant groups.
-
.find(key) ⇒ ConstantGroup
(also: [])
Find a constant group by its key.
Instance Method Summary collapse
-
#find(name) ⇒ Constant::Map
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
#initialize(key, constants) ⇒ Group
Returns a new instance of Group.
53 54 55 56 |
# File 'lib/midi-message/constant.rb', line 53 def initialize(key, constants) @key = key @constants = constants.map { |k, v| Constant::Map.new(k, v) } end |
Instance Attribute Details
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
49 50 51 |
# File 'lib/midi-message/constant.rb', line 49 def constants @constants end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
49 50 51 |
# File 'lib/midi-message/constant.rb', line 49 def key @key end |
Class Method Details
.all ⇒ Array<ConstantGroup>
All constant groups
76 77 78 79 |
# File 'lib/midi-message/constant.rb', line 76 def all ensure_initialized @groups end |
.find(key) ⇒ ConstantGroup Also known as: []
Find a constant group by its key
84 85 86 87 |
# File 'lib/midi-message/constant.rb', line 84 def find(key) ensure_initialized @groups.find { |group| Name.match?(group.key, key) } end |
Instance Method Details
#find(name) ⇒ Constant::Map
Find a constant by its name
61 62 63 |
# File 'lib/midi-message/constant.rb', line 61 def find(name) @constants.find { |const| Name.match?(const.key, name) } end |
#find_by_value(value) ⇒ Constant::Map
Find a constant by its value
68 69 70 |
# File 'lib/midi-message/constant.rb', line 68 def find_by_value(value) @constants.find { |const| Name.match?(const.value, value) } end |