Class: MIDIEvents::Constant::Group
- Inherits:
-
Object
- Object
- MIDIEvents::Constant::Group
- Defined in:
- lib/midi-events/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.
48 49 50 51 |
# File 'lib/midi-events/constant.rb', line 48 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.
44 45 46 |
# File 'lib/midi-events/constant.rb', line 44 def constants @constants end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
44 45 46 |
# File 'lib/midi-events/constant.rb', line 44 def key @key end |
Class Method Details
.all ⇒ Array<ConstantGroup>
All constant groups
70 71 72 73 |
# File 'lib/midi-events/constant.rb', line 70 def all ensure_initialized @groups end |
.find(key) ⇒ ConstantGroup Also known as: []
Find a constant group by its key
78 79 80 81 |
# File 'lib/midi-events/constant.rb', line 78 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
56 57 58 |
# File 'lib/midi-events/constant.rb', line 56 def find(name) @constants.find { |const| Name.match?(const.key, name) } end |
#find_by_value(value) ⇒ Constant::Map
Find a constant by its value
63 64 65 |
# File 'lib/midi-events/constant.rb', line 63 def find_by_value(value) @constants.find { |const| Name.match?(const.value, value) } end |