Class: Sanford::Protocol::PackedHeader

Inherits:
Struct
  • Object
show all
Defined in:
lib/sanford-protocol.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bytesObject

Returns the value of attribute bytes

Returns:

  • (Object)

    the current value of bytes



35
36
37
# File 'lib/sanford-protocol.rb', line 35

def bytes
  @bytes
end

#directiveObject

Returns the value of attribute directive

Returns:

  • (Object)

    the current value of directive



35
36
37
# File 'lib/sanford-protocol.rb', line 35

def directive
  @directive
end

Instance Method Details

#decode(binary) ⇒ Object



37
# File 'lib/sanford-protocol.rb', line 37

def decode(binary); binary.to_s.unpack(directive).first; end

#encode(data) ⇒ Object



36
# File 'lib/sanford-protocol.rb', line 36

def encode(data);   [*data].pack(directive);             end