module Gogyou::Extensions::ByteArray
.bytesize・.byteslice・.setbinary・.getbyte・.setbyte メソッドを用いて 整数値・実数値を埋め込む・取り出すメソッドを定義します。
gogyou は ruby の String
や Fiddle::Pointer
、FFI::AbstractPointer クラスにこのモジュールを include しています。
Public Instance Methods
load_char(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 734 def load_char(index) byteslice(index, TypeSpec::SIZEOF_CHAR).unpack("c!")[0] end
load_double(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 802 def load_double(index) byteslice(index, TypeSpec::SIZEOF_DOUBLE).unpack("d")[0] end
load_float(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 794 def load_float(index) byteslice(index, TypeSpec::SIZEOF_FLOAT).unpack("f")[0] end
load_int(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 758 def load_int(index) byteslice(index, TypeSpec::SIZEOF_INT).unpack("i!")[0] end
Also aliased as: load_ssizet
load_long(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 770 def load_long(index) byteslice(index, TypeSpec::SIZEOF_LONG).unpack("l!")[0] end
Also aliased as: load_ssizet
load_longlong(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 782 def load_longlong(index) byteslice(index, TypeSpec::SIZEOF_LONGLONG).unpack("q")[0] end
Also aliased as: load_ssizet
load_short(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 746 def load_short(index) byteslice(index, TypeSpec::SIZEOF_SHORT).unpack("s!")[0] end
load_uchar(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 738 def load_uchar(index) byteslice(index, TypeSpec::SIZEOF_CHAR).unpack("C!")[0] end
load_uint(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 762 def load_uint(index) byteslice(index, TypeSpec::SIZEOF_INT).unpack("I!")[0] end
Also aliased as: load_sizet
load_ulong(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 774 def load_ulong(index) byteslice(index, TypeSpec::SIZEOF_LONG).unpack("L!")[0] end
Also aliased as: load_sizet
load_ulonglong(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 786 def load_ulonglong(index) byteslice(index, TypeSpec::SIZEOF_LONGLONG).unpack("Q")[0] end
Also aliased as: load_sizet
load_ushort(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 750 def load_ushort(index) byteslice(index, TypeSpec::SIZEOF_SHORT).unpack("S!")[0] end
loadf16(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 349 def loadf16(index) loadu16(index).unpack_binary16 end
loadf16be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 365 def loadf16be(index) loadu16be(index).unpack_binary16 end
loadf16le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 373 def loadf16le(index) loadu16le(index).unpack_binary16 end
loadf16swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 357 def loadf16swap(index) loadu16swap(index).unpack_binary16 end
loadf32(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 381 def loadf32(index) loadu32(index).unpack_binary32 end
loadf32be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 397 def loadf32be(index) loadu32be(index).unpack_binary32 end
loadf32le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 405 def loadf32le(index) loadu32le(index).unpack_binary32 end
loadf32swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 389 def loadf32swap(index) loadu32swap(index).unpack_binary32 end
loadf64(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 413 def loadf64(index) loadu64(index).unpack_binary64 end
loadf64be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 429 def loadf64be(index) loadu64be(index).unpack_binary64 end
loadf64le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 437 def loadf64le(index) loadu64le(index).unpack_binary64 end
loadf64swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 421 def loadf64swap(index) loadu64swap(index).unpack_binary64 end
loadi16(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 101 def loadi16(index) byteslice(index, 2).unpack("s")[0] end
loadi16be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 133 def loadi16be(index) (getbyte(index).extendsign_char << 8) | (getbyte(index + 1)) end
loadi16le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 150 def loadi16le(index) (getbyte(index)) | (getbyte(index + 1).extendsign_char << 8) end
loadi16q8(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 445 def loadi16q8(index) loadi16(index) / 256.0 end
loadi16q8be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 469 def loadi16q8be(index) loadi16be(index) / 256.0 end
loadi16q8le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 481 def loadi16q8le(index) loadi16le(index) / 256.0 end
loadi16q8swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 457 def loadi16q8swap(index) loadi16swap(index) / 256.0 end
loadi16swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 113 def loadi16swap(index) byteslice(index, 2).unpack("s")[0].swap16s end
loadi24be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 169 def loadi24be(index) (getbyte(index).extendsign_char << 16) | (getbyte(index + 1) << 8) | (getbyte(index + 2)) end
loadi24le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 189 def loadi24le(index) (getbyte(index)) | (getbyte(index + 1) << 8) | (getbyte(index + 2).extendsign_char << 16) end
loadi32(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 199 def loadi32(index) byteslice(index, 4).unpack("l")[0] end
loadi32be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 235 def loadi32be(index) (getbyte(index).extendsign_char << 24) | (getbyte(index + 1) << 16) | (getbyte(index + 2) << 8) | (getbyte(index + 3)) end
loadi32le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 258 def loadi32le(index) (getbyte(index)) | (getbyte(index + 1) << 8) | (getbyte(index + 2) << 16) | (getbyte(index + 3).extendsign_char << 24) end
loadi32q12(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 589 def loadi32q12(index) loadi32(index) / 4096.0 end
loadi32q12be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 613 def loadi32q12be(index) loadi32be(index) / 4096.0 end
loadi32q12le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 625 def loadi32q12le(index) loadi32le(index) / 4096.0 end
loadi32q12swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 601 def loadi32q12swap(index) loadi32swap(index) / 4096.0 end
loadi32q16(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 637 def loadi32q16(index) loadi32(index) / 65536.0 end
loadi32q16be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 661 def loadi32q16be(index) loadi32be(index) / 65536.0 end
loadi32q16le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 673 def loadi32q16le(index) loadi32le(index) / 65536.0 end
loadi32q16swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 649 def loadi32q16swap(index) loadi32swap(index) / 65536.0 end
loadi32q24(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 685 def loadi32q24(index) loadi32(index) / 16777216.0 end
loadi32q24be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 709 def loadi32q24be(index) loadi32be(index) / 16777216.0 end
loadi32q24le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 721 def loadi32q24le(index) loadi32le(index) / 16777216.0 end
loadi32q24swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 697 def loadi32q24swap(index) loadi32swap(index) / 16777216.0 end
loadi32q6(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 493 def loadi32q6(index) loadi32(index) / 64.0 end
loadi32q6be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 517 def loadi32q6be(index) loadi32be(index) / 64.0 end
loadi32q6le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 529 def loadi32q6le(index) loadi32le(index) / 64.0 end
loadi32q6swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 505 def loadi32q6swap(index) loadi32swap(index) / 64.0 end
loadi32q8(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 541 def loadi32q8(index) loadi32(index) / 256.0 end
loadi32q8be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 565 def loadi32q8be(index) loadi32be(index) / 256.0 end
loadi32q8le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 577 def loadi32q8le(index) loadi32le(index) / 256.0 end
loadi32q8swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 553 def loadi32q8swap(index) loadi32swap(index) / 256.0 end
loadi32swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 211 def loadi32swap(index) byteslice(index, 4).unpack("l")[0].swap32s end
loadi48be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 275 def loadi48be(index) (loadi24be(index) << 24) | loadu24be(index + 3) end
loadi48le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 289 def loadi48le(index) loadu24le(index) | (loadi24le(index + 3) << 24) end
loadi64(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 297 def loadi64(index) byteslice(index, 8).unpack("q")[0] end
loadi64be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 327 def loadi64be(index) (loadi32be(index) << 32) | loadu32be(index + 4) end
loadi64le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 341 def loadi64le(index) loadu32le(index) | (loadi32le(index + 4) << 32) end
loadi64swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 309 def loadi64swap(index) byteslice(index, 8).unpack("q")[0].swap64s end
loadi8(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 93 def loadi8(index) getbyte(index).extendsign_char end
loadibe(index, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 65 def loadibe(index, bytesize) loadube(index, bytesize).extendsign(bytesize * BITS_PER_BYTE) end
Also aliased as: loadi, loadiswap
loadile(index, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 81 def loadile(index, bytesize) loadule(index, bytesize).extendsign(bytesize * BITS_PER_BYTE) end
Also aliased as: loadiswap, loadi
loadu16(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 105 def loadu16(index) byteslice(index, 2).unpack("S")[0] end
loadu16be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 128 def loadu16be(index) (getbyte(index) << 8) | (getbyte(index + 1)) end
loadu16le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 145 def loadu16le(index) (getbyte(index)) | (getbyte(index + 1) << 8) end
loadu16q8(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 449 def loadu16q8(index) loadu16(index) / 256.0 end
loadu16q8be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 473 def loadu16q8be(index) loadu16be(index) / 256.0 end
loadu16q8le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 485 def loadu16q8le(index) loadu16le(index) / 256.0 end
loadu16q8swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 461 def loadu16q8swap(index) loadu16swap(index) / 256.0 end
loadu16swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 117 def loadu16swap(index) byteslice(index, 2).unpack("S")[0].swap16 end
loadu24be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 163 def loadu24be(index) (getbyte(index) << 16) | (getbyte(index + 1) << 8) | (getbyte(index + 2)) end
loadu24le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 183 def loadu24le(index) (getbyte(index)) | (getbyte(index + 1) << 8) | (getbyte(index + 2) << 16) end
loadu32(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 203 def loadu32(index) byteslice(index, 4).unpack("L")[0] end
loadu32be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 228 def loadu32be(index) (getbyte(index) << 24) | (getbyte(index + 1) << 16) | (getbyte(index + 2) << 8) | (getbyte(index + 3)) end
loadu32le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 251 def loadu32le(index) (getbyte(index)) | (getbyte(index + 1) << 8) | (getbyte(index + 2) << 16) | (getbyte(index + 3) << 24) end
loadu32q12(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 593 def loadu32q12(index) loadu32(index) / 4096.0 end
loadu32q12be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 617 def loadu32q12be(index) loadu32be(index) / 4096.0 end
loadu32q12le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 629 def loadu32q12le(index) loadu32le(index) / 4096.0 end
loadu32q12swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 605 def loadu32q12swap(index) loadu32swap(index) / 4096.0 end
loadu32q16(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 641 def loadu32q16(index) loadu32(index) / 65536.0 end
loadu32q16be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 665 def loadu32q16be(index) loadu32be(index) / 65536.0 end
loadu32q16le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 677 def loadu32q16le(index) loadu32le(index) / 65536.0 end
loadu32q16swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 653 def loadu32q16swap(index) loadu32swap(index) / 65536.0 end
loadu32q24(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 689 def loadu32q24(index) loadu32(index) / 16777216.0 end
loadu32q24be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 713 def loadu32q24be(index) loadu32be(index) / 16777216.0 end
loadu32q24le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 725 def loadu32q24le(index) loadu32le(index) / 16777216.0 end
loadu32q24swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 701 def loadu32q24swap(index) loadu32swap(index) / 16777216.0 end
loadu32q6(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 497 def loadu32q6(index) loadu32(index) / 64.0 end
loadu32q6be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 521 def loadu32q6be(index) loadu32be(index) / 64.0 end
loadu32q6le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 533 def loadu32q6le(index) loadu32le(index) / 64.0 end
loadu32q6swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 509 def loadu32q6swap(index) loadu32swap(index) / 64.0 end
loadu32q8(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 545 def loadu32q8(index) loadu32(index) / 256.0 end
loadu32q8be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 569 def loadu32q8be(index) loadu32be(index) / 256.0 end
loadu32q8le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 581 def loadu32q8le(index) loadu32le(index) / 256.0 end
loadu32q8swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 557 def loadu32q8swap(index) loadu32swap(index) / 256.0 end
loadu32swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 215 def loadu32swap(index) byteslice(index, 4).unpack("L")[0].swap32 end
loadu48be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 271 def loadu48be(index) (loadu24be(index) << 24) | loadu24be(index + 3) end
loadu48le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 285 def loadu48le(index) loadu24le(index) | (loadu24le(index + 3) << 24) end
loadu64(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 301 def loadu64(index) byteslice(index, 8).unpack("Q")[0] end
loadu64be(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 323 def loadu64be(index) (loadu32be(index) << 32) | loadu32be(index + 4) end
loadu64le(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 337 def loadu64le(index) loadu32le(index) | (loadu32le(index + 4) << 32) end
loadu64swap(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 313 def loadu64swap(index) byteslice(index, 8).unpack("Q")[0].swap64 end
loadu8(index)
click to toggle source
# File lib/gogyou/bytearray.rb, line 89 def loadu8(index) getbyte(index) end
loadube(index, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 54 def loadube(index, bytesize) n = 0 while bytesize > 0 bytesize -= 1 n <<= BITS_PER_BYTE n |= getbyte(index) index += 1 end n end
Also aliased as: loadu, loaduswap
loadule(index, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 69 def loadule(index, bytesize) n = 0 c = 0 while bytesize > 0 bytesize -= 1 n |= getbyte(index) << (BITS_PER_BYTE * c) index += 1 c += 1 end n end
Also aliased as: loaduswap, loadu
store16(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 97 def store16(index, num) setbinary(index, [num].pack("S")) end
store16be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 121 def store16be(index, num) index = index.to_i num = 0xffff & num.to_i setbyte(index , num >> 8) setbyte(index + 1, num ) end
store16le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 138 def store16le(index, num) index = index.to_i num = 0xffff & num.to_i setbyte(index , num ) setbyte(index + 1, num >> 8) end
store16q8(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 441 def store16q8(index, num) store16(index, num * 256) end
store16q8be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 465 def store16q8be(index, num) store16be(index, num * 256) end
store16q8le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 477 def store16q8le(index, num) store16le(index, num * 256) end
store16q8swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 453 def store16q8swap(index, num) store16swap(index, num * 256) end
store16swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 109 def store16swap(index, num) setbinary(index, [num.swap16].pack("S")) end
store24be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 155 def store24be(index, num) index = index.to_i num = 0xffffff & num.to_i setbyte(index , num >> 16) setbyte(index + 1, num >> 8) setbyte(index + 2, num ) end
store24le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 175 def store24le(index, num) index = index.to_i num = 0xffffff & num.to_i setbyte(index , num ) setbyte(index + 1, num >> 8) setbyte(index + 2, num >> 16) end
store32(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 195 def store32(index, num) setbinary(index, [num].pack("L")) end
store32be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 219 def store32be(index, num) index = index.to_i num = 0xffffffff & num.to_i setbyte(index , num >> 24) setbyte(index + 1, num >> 16) setbyte(index + 2, num >> 8) setbyte(index + 3, num & 0xff) end
store32le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 242 def store32le(index, num) index = index.to_i num = 0xffffffff & num.to_i setbyte(index , num & 0xff) setbyte(index + 1, num >> 8) setbyte(index + 2, num >> 16) setbyte(index + 3, num >> 24) end
store32q12(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 585 def store32q12(index, num) store32(index, num * 4096) end
store32q12be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 609 def store32q12be(index, num) store32be(index, num * 4096) end
store32q12le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 621 def store32q12le(index, num) store32le(index, num * 4096) end
store32q12swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 597 def store32q12swap(index, num) store32swap(index, num * 4096) end
store32q16(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 633 def store32q16(index, num) store32(index, num * 65536) end
store32q16be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 657 def store32q16be(index, num) store32be(index, num * 65536) end
store32q16le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 669 def store32q16le(index, num) store32le(index, num * 65536) end
store32q16swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 645 def store32q16swap(index, num) store32swap(index, num * 65536) end
store32q24(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 681 def store32q24(index, num) store32(index, num * 16777216) end
store32q24be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 705 def store32q24be(index, num) store32be(index, num * 16777216) end
store32q24le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 717 def store32q24le(index, num) store32le(index, num * 16777216) end
store32q24swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 693 def store32q24swap(index, num) store32swap(index, num * 16777216) end
store32q6(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 489 def store32q6(index, num) store32(index, num * 64) end
store32q6be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 513 def store32q6be(index, num) store32be(index, num * 64) end
store32q6le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 525 def store32q6le(index, num) store32le(index, num * 64) end
store32q6swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 501 def store32q6swap(index, num) store32swap(index, num * 64) end
store32q8(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 537 def store32q8(index, num) store32(index, num * 256) end
store32q8be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 561 def store32q8be(index, num) store32be(index, num * 256) end
store32q8le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 573 def store32q8le(index, num) store32le(index, num * 256) end
store32q8swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 549 def store32q8swap(index, num) store32swap(index, num * 256) end
store32swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 207 def store32swap(index, num) setbinary(index, [num.swap32].pack("L")) end
store48be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 265 def store48be(index, num) num = num.to_i store24be(index , num >> 24) store24be(index + 3, num ) end
store48le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 279 def store48le(index, num) num = num.to_i store24le(index , num ) store24le(index + 3, num >> 24) end
store64(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 293 def store64(index, num) setbinary(index, [num].pack("Q")) end
store64be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 317 def store64be(index, num) num = num.to_i store32be(index , num >> 32) store32be(index + 4, num ) end
store64le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 331 def store64le(index, num) num = num.to_i store32le(index , num ) store32le(index + 4, num >> 32) end
store64swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 305 def store64swap(index, num) setbinary(index, [num.swap64].pack("Q")) end
store8(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 85 def store8(index, num) setbyte(index.to_i, 0xff & num.to_i) end
store_char(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 730 def store_char(index, num) setbinary(index, [num].pack("S!")) end
store_double(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 798 def store_double(index, num) setbinary(index, [num].pack("d")) end
store_float(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 790 def store_float(index, num) setbinary(index, [num].pack("f")) end
store_int(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 754 def store_int(index, num) setbinary(index, [num].pack("I!")) end
Also aliased as: store_sizet
store_long(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 766 def store_long(index, num) setbinary(index, [num].pack("L!")) end
Also aliased as: store_sizet
store_longlong(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 778 def store_longlong(index, num) setbinary(index, [num].pack("Q")) end
Also aliased as: store_sizet
store_short(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 742 def store_short(index, num) setbinary(index, [num].pack("S!")) end
storebe(index, num, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 25 def storebe(index, num, bytesize) raise RangeError unless index >= 0 && index < bytesize && index + bytesize <= bytesize() && index + bytesize >= 0 while bytesize > 0 bytesize -= 1 setbyte(index, 0xff & (num >> (bytesize * BITS_PER_BYTE))) index += 1 end self end
Also aliased as: store, storeswap
storef16(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 345 def storef16(index, num) store16(index, num.pack_binary16) end
storef16be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 361 def storef16be(index, num) store16be(index, num.pack_binary16) end
storef16le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 369 def storef16le(index, num) store16le(index, num.pack_binary16) end
storef16swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 353 def storef16swap(index, num) store16swap(index, num.pack_binary16) end
storef32(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 377 def storef32(index, num) store32(index, num.pack_binary32) end
storef32be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 393 def storef32be(index, num) store32be(index, num.pack_binary32) end
storef32le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 401 def storef32le(index, num) store32le(index, num.pack_binary32) end
storef32swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 385 def storef32swap(index, num) store32swap(index, num.pack_binary32) end
storef64(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 409 def storef64(index, num) store64(index, num.pack_binary64) end
storef64be(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 425 def storef64be(index, num) store64be(index, num.pack_binary64) end
storef64le(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 433 def storef64le(index, num) store64le(index, num.pack_binary64) end
storef64swap(index, num)
click to toggle source
# File lib/gogyou/bytearray.rb, line 417 def storef64swap(index, num) store64swap(index, num.pack_binary64) end
storele(index, num, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 39 def storele(index, num, bytesize) raise RangeError unless index >= 0 && index < bytesize() && index + bytesize <= bytesize() && index + bytesize >= 0 while bytesize > 0 bytesize -= 1 setbyte(index, 0xff & num) num >>= BITS_PER_BYTE index += 1 end self end
Also aliased as: storeswap, store
swapbyte(index, bytesize)
click to toggle source
# File lib/gogyou/bytearray.rb, line 11 def swapbyte(index, bytesize) i = index.to_i j = i + bytesize.to_i - 1 while i < j w = getbyte(i) setbyte(i, getbyte(j)) setbyte(j, w) i += 1 j -= 1 end self end