Class: MIDIMessage::ConstantGroup
- Inherits:
-
Object
- Object
- MIDIMessage::ConstantGroup
- Defined in:
- lib/midi-message/constant.rb
Overview
MIDI Constants
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
Instance Method Summary collapse
- #find(name) ⇒ Object (also: #[])
- #find_by_value(value) ⇒ Object
-
#initialize(key, constants) ⇒ ConstantGroup
constructor
A new instance of ConstantGroup.
Constructor Details
#initialize(key, constants) ⇒ ConstantGroup
Returns a new instance of ConstantGroup.
11 12 13 14 |
# File 'lib/midi-message/constant.rb', line 11 def initialize(key, constants) @key = key @constants = constants.map { |k, v| Constant.new(k, v) } end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/midi-message/constant.rb', line 9 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/midi-message/constant.rb', line 9 def value @value end |
Class Method Details
.[](key) ⇒ Object
30 31 32 33 |
# File 'lib/midi-message/constant.rb', line 30 def self.[](key) ensure_initialized @groups.find { |g| g.key.to_s.downcase.eql?(key.to_s.downcase) } end |
.all ⇒ Object
25 26 27 28 |
# File 'lib/midi-message/constant.rb', line 25 def self.all ensure_initialized @groups end |
Instance Method Details
#find(name) ⇒ Object Also known as: []
16 17 18 |
# File 'lib/midi-message/constant.rb', line 16 def find(name) @constants.find { |const| const.key.to_s.downcase.eql?(name.to_s.downcase) } end |
#find_by_value(value) ⇒ Object
21 22 23 |
# File 'lib/midi-message/constant.rb', line 21 def find_by_value(value) @constants.find { |const| const.value.to_s.downcase.eql?(value.to_s.downcase) } end |