Module: MIDIMessage::ShortMessage::ClassMethods

Defined in:
lib/midi-message/short_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#constantsObject (readonly)

Returns the value of attribute constants.



65
66
67
# File 'lib/midi-message/short_message.rb', line 65

def constants
  @constants
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



65
66
67
# File 'lib/midi-message/short_message.rb', line 65

def display_name
  @display_name
end

#map_constants_toObject (readonly)

Returns the value of attribute map_constants_to.



65
66
67
# File 'lib/midi-message/short_message.rb', line 65

def map_constants_to
  @map_constants_to
end

Instance Method Details

#[](const_name) ⇒ Object

this returns a builder for the class, preloaded with the selected const



76
77
78
79
# File 'lib/midi-message/short_message.rb', line 76

def [](const_name)
  const = get_constant(const_name)
  MessageBuilder.new(self, const) unless const.nil?
end

#get_constant(name) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/midi-message/short_message.rb', line 67

def get_constant(name)        
  key = @constants || @display_name
  unless key.nil?
    group = ConstantGroup[key]
    group.find(name)
  end 
end

#use_constants(name, options = {}) ⇒ Object



85
86
87
88
# File 'lib/midi-message/short_message.rb', line 85

def use_constants(name, options = {}) 
  @map_constants_to = options[:for]
  @constants = name
end

#use_display_name(name) ⇒ Object



81
82
83
# File 'lib/midi-message/short_message.rb', line 81

def use_display_name(name)
  @display_name = name
end