Module: MonkeyPatch::Uint::BaseConversions
- Defined in:
- lib/pio/monkey_patch/uint/base_conversions.rb
Overview
Uint8#to_bytes, Uintxxbe#to_bytes
Instance Method Summary collapse
Instance Method Details
#to_bytes ⇒ Object
7 8 9 10 11 12 13 |
# 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 |