class YARP::Pack::Directive

Constants

ENDIAN_DESCRIPTIONS
SIGNED_DESCRIPTIONS
SIZE_DESCRIPTIONS

Attributes

endian[R]
length[R]
length_type[R]
signed[R]
size[R]
source[R]
type[R]
variant[R]
version[R]

Public Class Methods

new(version, variant, source, type, signed, endian, size, length_type, length) click to toggle source
# File yarp/pack.rb, line 60
def initialize(version, variant, source, type, signed, endian, size, length_type, length)
  @version = version
  @variant = variant
  @source = source
  @type = type
  @signed = signed
  @endian = endian
  @size = size
  @length_type = length_type
  @length = length
end

Public Instance Methods

describe() click to toggle source
# File yarp/pack.rb, line 98
def describe
  case type
  when SPACE
    'whitespace'
  when COMMENT
    'comment'
  when INTEGER
    if size == SIZE_8
      base = "#{SIGNED_DESCRIPTIONS[signed]} #{SIZE_DESCRIPTIONS[size]} integer"
    else
      base = "#{SIGNED_DESCRIPTIONS[signed]} #{SIZE_DESCRIPTIONS[size]} #{ENDIAN_DESCRIPTIONS[endian]} integer"
    end
    case length_type
    when LENGTH_FIXED
      if length > 1
        base + ", x#{length}"
      else
        base
      end
    when LENGTH_MAX
      base + ', as many as possible'
    end
  when UTF8
    'UTF-8 character'
  when BER
    'BER-compressed integer'
  when FLOAT
    "#{SIZE_DESCRIPTIONS[size]} #{ENDIAN_DESCRIPTIONS[endian]} float"
  when STRING_SPACE_PADDED
    'arbitrary binary string (space padded)'
  when STRING_NULL_PADDED
    'arbitrary binary string (null padded, count is width)'
  when STRING_NULL_TERMINATED
    'arbitrary binary string (null padded, count is width), except that null is added with *'
  when STRING_MSB
    'bit string (MSB first)'
  when STRING_LSB
    'bit string (LSB first)'
  when STRING_HEX_HIGH
    'hex string (high nibble first)'
  when STRING_HEX_LOW
    'hex string (low nibble first)'
  when STRING_UU
    'UU-encoded string'
  when STRING_MIME
    'quoted printable, MIME encoding'
  when STRING_BASE64
    'base64 encoded string'
  when STRING_FIXED
    'pointer to a structure (fixed-length string)'
  when STRING_POINTER
    'pointer to a null-terminated string'
  when MOVE
    'move to absolute position'
  when BACK
    'back up a byte'
  when NULL
    'null byte'
  else
    raise
  end
end