Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/rqtrotate/extensions.rb
Overview
ruby’s pack can’t build signed big-endian longs (although I’m going to submit a patch to ruby-core to do so). this method compensates for that.
Instance Method Summary collapse
Instance Method Details
#signed_bigendian_pack ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rqtrotate/extensions.rb', line 41 def signed_bigendian_pack() if [1, 0].pack("N*") == [1, 0].pack("L*") pack('c*') else result = '' each do |i| br = '' 4.times do br << (i & 0xFF) i >>= 8 end result << br.reverse! end result end end |