Class: Webmidi::Message::UMP::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/webmidi/message/ump.rb

Direct Known Subclasses

ChannelVoice32, ChannelVoice64, Raw

Instance Attribute Summary collapse

Attributes inherited from Base

#timestamp

Instance Method Summary collapse

Methods inherited from Base

#==, #channel, #deconstruct, #eql?, #hash, #same_bytes?, #same_event?, #to_binary, #to_bytes, #to_hex

Constructor Details

#initialize(message_type:, group: 0, timestamp: nil) ⇒ Base

Returns a new instance of Base.



92
93
94
95
96
97
98
# File 'lib/webmidi/message/ump.rb', line 92

def initialize(message_type:, group: 0, timestamp: nil)
  validate_message_type!(message_type)
  validate_range!(group, "Group", 0, 15)
  @message_type = message_type
  @group = group
  super(timestamp: timestamp)
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



90
91
92
# File 'lib/webmidi/message/ump.rb', line 90

def group
  @group
end

#message_typeObject (readonly)

Returns the value of attribute message_type.



90
91
92
# File 'lib/webmidi/message/ump.rb', line 90

def message_type
  @message_type
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



100
101
102
# File 'lib/webmidi/message/ump.rb', line 100

def deconstruct_keys(keys)
  {message_type: @message_type, group: @group}
end

#with(**changes) ⇒ Object



104
105
106
107
108
# File 'lib/webmidi/message/ump.rb', line 104

def with(**changes)
  changes = changes.dup
  next_timestamp = changes.key?(:timestamp) ? changes.delete(:timestamp) : @timestamp
  self.class.new(**constructor_attributes.merge(changes), timestamp: next_timestamp)
end