Class: LibSL::LLU64

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



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/types.rb', line 186

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

Instance Method Details

#encodeObject

Raises:

  • (ArgumentError)


202
203
204
205
206
207
# File 'lib/types.rb', line 202

def encode()
	raise ArgumentError, "Value out of range: #{@value}" if @value < 0 or @value > 0xffffffffffffffff
	ms = @value >> 32
	ls = @value - (ms << 32)
	[ls, ms].pack('V2')
end