class BitStream::Signed

Public Class Methods

instance(props, bit_width) click to toggle source
# File lib/types/integer.rb, line 102
def self.instance(props, bit_width)
  unsigned = Unsigned.instance(props, bit_width)
  return @instances[unsigned]
end
new(unsigned) click to toggle source
# File lib/types/integer.rb, line 107
def initialize(unsigned)
  @unsigned = unsigned
end

Public Instance Methods

length() click to toggle source
# File lib/types/integer.rb, line 111
def length
  @unsigned.length
end
read(s, offset) click to toggle source
# File lib/types/integer.rb, line 115
def read(s, offset)
  info = @unsigned.read(s, offset)
  val = info[:value]
  len = info[:length]
  mask = -1 << (len - 1)
  if (val & mask) != 0
    val |= mask
  end
  return FieldInfo.new(val, len)
end
write(s, offset, value) click to toggle source
# File lib/types/integer.rb, line 126
def write(s, offset, value)
  mask = ~(-1 << len)
  value &= mask
  return @unsigned.write(s, offset, value)
end