lib/ronin/formatting/extensions/binary/integer.rb in ronin-support-0.2.0 vs lib/ronin/formatting/extensions/binary/integer.rb in ronin-support-0.3.0
- old
+ new
@@ -25,19 +25,26 @@
# @param [Integer] address_length
# The number of bytes to decode from the Integer.
#
# @param [Symbol, String] endian
# The endianness to use while decoding the bytes of the Integer.
- # May be either `:big`, `:little` or `:net`.
+ # May be one of:
#
+ # * `:big` / `"big"`
+ # * `:little` / `"little"`
+ # * `:net` / `"net"`
+ #
# @return [Array]
# The bytes decoded from the Integer.
#
# @raise [ArgumentError]
- # The given `endian` is not `:little`, `"little"`, `:net`, `"net"`,
- # `:big` or `"big"`.
+ # The given `endian` was not one of:
#
+ # * `:little` / `"little"`
+ # * `:net` / `"net"`
+ # * `:big` / `"big"`
+ #
# @example
# 0xff41.bytes(2)
# # => [65, 255]
#
# @example
@@ -50,21 +57,21 @@
endian = endian.to_sym
buffer = []
case endian
when :little, :net
- mask = 0xff
+ mask = 0xff
shift = 0
address_length.times do |i|
buffer << ((self & mask) >> shift)
mask <<= 8
shift += 8
end
when :big
shift = ((address_length - 1) * 8)
- mask = (0xff << shift)
+ mask = (0xff << shift)
address_length.times do |i|
buffer << ((self & mask) >> shift)
mask >>= 8