Class: Webmidi::Message::System::SongSelect

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

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_hex, #with

Constructor Details

#initialize(song:, timestamp: nil) ⇒ SongSelect

Returns a new instance of SongSelect.



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

def initialize(song:, timestamp: nil)
  unless song.is_a?(Integer) && song.between?(0, 127)
    raise InvalidMessageError, "Song number must be between 0 and 127, got #{song.inspect}"
  end
  @song = song
  super(timestamp: timestamp)
end

Instance Attribute Details

#songObject (readonly)

Returns the value of attribute song.



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

def song
  @song
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



114
115
116
# File 'lib/webmidi/message/system.rb', line 114

def deconstruct_keys(keys)
  {song: @song}
end

#to_bytesObject



110
111
112
# File 'lib/webmidi/message/system.rb', line 110

def to_bytes
  [0xF3, @song]
end