Class: Webmidi::Message::System::SongPosition
- Defined in:
- lib/webmidi/message/system.rb
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Attributes inherited from Base
Instance Method Summary collapse
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(position:, timestamp: nil) ⇒ SongPosition
constructor
A new instance of SongPosition.
- #to_bytes ⇒ Object
Methods inherited from Base
#==, #channel, #deconstruct, #eql?, #hash, #same_bytes?, #same_event?, #to_binary, #to_hex, #with
Constructor Details
#initialize(position:, timestamp: nil) ⇒ SongPosition
Returns a new instance of SongPosition.
82 83 84 85 86 87 88 |
# File 'lib/webmidi/message/system.rb', line 82 def initialize(position:, timestamp: nil) unless position.is_a?(Integer) && position.between?(0, 16383) raise InvalidMessageError, "Song position must be between 0 and 16383, got #{position.inspect}" end @position = position super(timestamp: ) end |
Instance Attribute Details
#position ⇒ Object (readonly)
Returns the value of attribute position.
80 81 82 |
# File 'lib/webmidi/message/system.rb', line 80 def position @position end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
94 95 96 |
# File 'lib/webmidi/message/system.rb', line 94 def deconstruct_keys(keys) {position: @position} end |
#to_bytes ⇒ Object
90 91 92 |
# File 'lib/webmidi/message/system.rb', line 90 def to_bytes [0xF2, @position & 0x7F, (@position >> 7) & 0x7F] end |