class Hexdump::Numeric::Hexadecimal
@api private
@since 1.0.0
Constants
- FLOAT_WIDTH
- INT_SIZE_TO_WIDTH
Attributes
width[R]
@return [Integer]
Public Class Methods
new(type)
click to toggle source
Initializes the hexadecimal format.
@param [Type::Int, Type::UInt
, Type::Float] type
Calls superclass method
Hexdump::FormatString::new
# File lib/hexdump/numeric/hexadecimal.rb, line 29 def initialize(type) case type when Type::Float if RUBY_ENGINE == 'jruby' # XXX: https://github.com/jruby/jruby/issues/5122 begin "%a" % 1.0 rescue ArgumentError raise(NotImplementedError,"jruby #{RUBY_ENGINE_VERSION} does not support the \"%a\" format string") end end # NOTE: jruby does not currently support the %a format string @width = FLOAT_WIDTH super("% #{@width}a"); @width += 1 else @width = INT_SIZE_TO_WIDTH.fetch(type.size) do raise(NotImplementedError,"type #{type} with unsupported size #{type.size}") end if type.signed? super("% .#{@width}x"); @width += 1 else super("%.#{@width}x") end end end