Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/struct_ex/struct_ex.rb

Instance Method Summary collapse

Instance Method Details

#to_bytes(size) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/ffi/struct_ex/struct_ex.rb', line 4

def to_bytes(size)
  bytes = [0] * size
  bytes.each_index do |i|
    bytes[i] = (self >> (i * 8)) & 0xff
  end

  bytes
end