Class: MIDIMessage::ConstantGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/midi-message/constant.rb

Overview

MIDI Constants

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/midi-message/constant.rb', line 9

def key
  @key
end

#valueObject (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

.allObject



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