Class: Webmidi::Message::System::SongSelect
- Defined in:
- lib/webmidi/message/system.rb
Instance Attribute Summary collapse
-
#song ⇒ Object
readonly
Returns the value of attribute song.
Attributes inherited from Base
Instance Method Summary collapse
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(song:, timestamp: nil) ⇒ SongSelect
constructor
A new instance of SongSelect.
- #to_bytes ⇒ Object
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: ) end |
Instance Attribute Details
#song ⇒ Object (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_bytes ⇒ Object
110 111 112 |
# File 'lib/webmidi/message/system.rb', line 110 def to_bytes [0xF3, @song] end |