Module: MIDIEvents::SystemExclusive::InstanceMethods

Included in:
Message
Defined in:
lib/midi-events/system_exclusive.rb

Overview

Common SysEx data that a message class will contain

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



14
15
16
# File 'lib/midi-events/system_exclusive.rb', line 14

def address
  @address
end

#checksumObject (readonly)



72
73
74
# File 'lib/midi-events/system_exclusive.rb', line 72

def checksum
  @checksum
end

#nodeObject

Returns the value of attribute node.



13
14
15
# File 'lib/midi-events/system_exclusive.rb', line 13

def node
  @node
end

Instance Method Details

#end_byteObject



62
63
64
# File 'lib/midi-events/system_exclusive.rb', line 62

def end_byte
  SystemExclusive::DELIMITER[:finish]
end

#nameObject Also known as: verbose_name



53
54
55
# File 'lib/midi-events/system_exclusive.rb', line 53

def name
  SystemExclusive::DISPLAY_NAME
end

#start_byteObject



58
59
60
# File 'lib/midi-events/system_exclusive.rb', line 58

def start_byte
  SystemExclusive::DELIMITER[:start]
end

#to_a(options = {}) ⇒ Object

an array of message parts. multiple byte parts will be represented as an array of bytes



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/midi-events/system_exclusive.rb', line 17

def to_a(options = {})
  omit = options[:omit] || []
  node = @node.to_a(options) unless @node.nil? || omit.include?(:node)
  # this may need to be cached when properties are updated
  # might be worth benchmarking
  [
    start_byte,
    node,
    (type_byte unless omit.include?(:type)),
    [address].compact.flatten,
    [value].compact.flatten,
    (checksum unless omit.include?(:checksum)),
    end_byte
  ].compact
end

#to_hex_sObject Also known as: to_bytestr

string representation of the object's bytes



43
44
45
46
47
48
49
50
# File 'lib/midi-events/system_exclusive.rb', line 43

def to_hex_s
  strings = to_bytes.map do |byte|
    string = byte.to_s(16)
    string = "0#{string}" if string.length == 1
    string
  end
  strings.join.upcase
end

#to_numeric_byte_array(options = {}) ⇒ Object Also known as: to_numeric_bytes, to_byte_array, to_bytes, to_byte_a

a flat array of message bytes



34
35
36
# File 'lib/midi-events/system_exclusive.rb', line 34

def to_numeric_byte_array(options = {})
  to_a(options).flatten
end

#type_byteObject



66
67
68
# File 'lib/midi-events/system_exclusive.rb', line 66

def type_byte
  self.class::TYPE
end