Class: Nibbler::MessageBuilder
- Inherits:
-
Object
- Object
- Nibbler::MessageBuilder
- Defined in:
- lib/nibbler/message_builder.rb
Constant Summary collapse
- CHANNEL_MESSAGE =
[ { :status => 0x8, :name => :note_off, :nibbles => 6 }, { :status => 0x9, :name => :note_on, :nibbles => 6 }, { :status => 0xA, :name => :polyphonic_aftertouch, :nibbles => 6 }, { :status => 0xB, :name => :control_change, :nibbles => 6 }, { :status => 0xC, :name => :program_change, :nibbles => 4 }, { :status => 0xD, :name => :channel_aftertouch, :nibbles => 4 }, { :status => 0xE, :name => :pitch_bend, :nibbles => 6 } ].freeze
- SYSTEM_MESSAGE =
[ { :status => 0x1..0x6, :name => :system_common, :nibbles => 6 }, { :status => 0x8..0xF, :name => :system_realtime, :nibbles => 2 } ].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#num_nibbles ⇒ Object
readonly
Returns the value of attribute num_nibbles.
Class Method Summary collapse
- .build_system_exclusive(library, *message_data) ⇒ Object
- .for_channel_message(library, status) ⇒ Object
- .for_system_message(library, status) ⇒ Object
Instance Method Summary collapse
- #build(*message_data) ⇒ Object
-
#initialize(library, name, num_nibbles) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
Constructor Details
#initialize(library, name, num_nibbles) ⇒ MessageBuilder
Returns a new instance of MessageBuilder.
72 73 74 75 76 |
# File 'lib/nibbler/message_builder.rb', line 72 def initialize(library, name, num_nibbles) @library = library @name = name @num_nibbles = num_nibbles end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
56 57 58 |
# File 'lib/nibbler/message_builder.rb', line 56 def name @name end |
#num_nibbles ⇒ Object (readonly)
Returns the value of attribute num_nibbles.
56 57 58 |
# File 'lib/nibbler/message_builder.rb', line 56 def num_nibbles @num_nibbles end |
Class Method Details
.build_system_exclusive(library, *message_data) ⇒ Object
58 59 60 |
# File 'lib/nibbler/message_builder.rb', line 58 def self.build_system_exclusive(library, *) library.system_exclusive(*) end |
.for_channel_message(library, status) ⇒ Object
67 68 69 70 |
# File 'lib/nibbler/message_builder.rb', line 67 def self.(library, status) type = CHANNEL_MESSAGE.find { |type| type[:status] == status } new(library, type[:name], type[:nibbles]) end |
.for_system_message(library, status) ⇒ Object
62 63 64 65 |
# File 'lib/nibbler/message_builder.rb', line 62 def self.(library, status) type = SYSTEM_MESSAGE.find { |type| type[:status].cover?(status) } new(library, type[:name], type[:nibbles]) end |
Instance Method Details
#build(*message_data) ⇒ Object
78 79 80 |
# File 'lib/nibbler/message_builder.rb', line 78 def build(*) @library.send(@name, *) end |