module MonkeyPatch::Uint::BaseConversions

Uint8#to_bytes, Uintxxbe#to_bytes

Public Instance Methods

to_bytes() click to toggle source
# File lib/pio/monkey_patch/uint/base_conversions.rb, line 7
def to_bytes
  /Uint(8|\d+be)$/=~ self.class.name
  nbyte = Regexp.last_match(1).to_i / 4
  format("%0#{nbyte}x", to_i).scan(/.{1,2}/).map do |each|
    '0x' + each
  end.join(', ')
end