Class: MIDIEvents::Constant::MessageBuilder Private
- Inherits:
-
Object
- Object
- MIDIEvents::Constant::MessageBuilder
- Defined in:
- lib/midi-events/constant.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Helper class for building messages with pre-bound constants
This class is returned when you call a message class's bracket method with a constant name (e.g., NoteOn["C4"]). It stores the constant and message class so that when you call #new, it creates the message with the constant value already filled in.
Instance Method Summary collapse
-
#initialize(klass, const) ⇒ MessageBuilder
constructor
private
Create a new message builder.
-
#new(*args) ⇒ MIDIEvents::Message
private
Create a message instance with the bound constant.
Constructor Details
#initialize(klass, const) ⇒ MessageBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new message builder
224 225 226 227 |
# File 'lib/midi-events/constant.rb', line 224 def initialize(klass, const) @klass = klass @const = const end |
Instance Method Details
#new(*args) ⇒ MIDIEvents::Message
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a message instance with the bound constant
233 234 235 236 237 |
# File 'lib/midi-events/constant.rb', line 233 def new(*args) args = args.dup args.last.is_a?(Hash) ? args.last[:const] = @const : args.push(const: @const) @klass.new(*args) end |