module PocketMiku::PacketFactory
Public Instance Methods
byte_check(byte, error_message="byte should 0...255 but give `%d'".freeze)
click to toggle source
# File lib/pocket_miku/packet_factory.rb, line 9 def byte_check(byte, error_message="byte should 0...255 but give `%d'".freeze) raise PocketMiku::InvalidByteError, "`#{byte}' is not integer." unless byte.is_a? Integer raise PocketMiku::InvalidByteError, error_message % byte unless (0..0xFF).include?(byte) byte end
pack(bytes)
click to toggle source
# File lib/pocket_miku/packet_factory.rb, line 3 def pack(bytes) bytes = [bytes] if bytes.is_a? Integer bytes.each(&PocketMiku::PacketFactory.method(:byte_check)) bytes.pack "C*".freeze end