Class: LibSL::LLS64

Inherits:
LLNumber show all
Defined in:
lib/types.rb

Instance Attribute Summary

Attributes inherited from LLNumber

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LLNumber

endianness, #initialize

Constructor Details

This class inherits a constructor from LibSL::LLNumber

Class Method Details

.decode(data) ⇒ Object



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/types.rb', line 267

def self.decode(data)
	s64, data = LLNumber.decode(data, 'q1a*', LLS64)
	if self.endianness == :big
		# Convert to little endian
		s64.value = s64.value >> 56 |
			(s64.value & 0xff000000000000) >> 40 |
			(s64.value & 0xff0000000000) >> 24 |
			(s64.value & 0xff00000000) >> 8 |
			(s64.value & 0xff000000) << 8 |
			(s64.value & 0xff0000) << 24 |
			(s64.value & 0xff00) << 40 |
			(s64.value & 0xff) << 56
	end
	return s64, data
end

Instance Method Details

#encodeObject

Raises:

  • (ArgumentError)


283
284
285
286
287
288
289
290
# File 'lib/types.rb', line 283

def encode()
	raise ArgumentError, "Value out of range: #{@value}" if @value < -0x8000000000000000 or @value > 0x7fffffffffffffff
	data = super('q')
	if LLNumber::endianness == :big
		data = data.unpack('C8').reverse.pack('C8')
	end
	return data
end