Project

cute-hex

0.0
No commit activity in last 3 years
No release in over 3 years
Format integer into its hexadecimal representation in string
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0

Runtime

 Project Readme

cute-hex

Cute Hex

Prettify your hex dump

require 'cute-hex'

a = 0xbeef

# Basic usage
CuteHex.x a                                                  # [0000 BEEF]
CuteHex.x nil                                                # [???? ????]
CuteHex.x a, style: :data                                    # 00 00 BE EF
CuteHex.x nil, style: :data                                  # ?? ?? ?? ??

# Adjust word size
CuteHex.x a, word_size: 64                                   # [0000 0000 0000 BEEF]
CuteHex.x a, style: :data, word_size: 16                     # BE EF

# Adjust slicer, only work with :data style
CuteHex.x a, word_size: 64, slicer: :nibble, style: :data    # 0000 0000 0000 BEEF
CuteHex.x a, word_size: 64, slicer: :half_word, style: :data # 00000000 0000BEEF
CuteHex.x a, word_size: 64, slicer: :word, style: :data      # 000000000000BEEF

# Remove trailing zeros, only work with :data style
CuteHex.x a, style: :data, pad_zeros: false                  #       BE EF
CuteHex.x nil, style: :data, pad_zeros: false                # ?? ?? ?? ??

Overriding default configuration

CuteHex.config.word_size=     # in bits, default is 32
CuteHex.config.pad_zeros=     # default is true
CuteHex.config.slicer=        # :byte (default), :nibble, :half_word, :word