class Hexdump::Numeric::Decimal
@api private
@since 1.0.0
Constants
- FLOAT_SIZE_TO_WIDTH
- INT_SIZE_TO_WIDTH
Attributes
width[R]
@return [Integer]
Public Class Methods
new(type)
click to toggle source
Initializes the decimal format.
@param [Type:Int, Type::UInt
, Type::Float] type
Calls superclass method
Hexdump::FormatString::new
# File lib/hexdump/numeric/decimal.rb, line 32 def initialize(type) widths = case type when Type::Float then FLOAT_SIZE_TO_WIDTH else INT_SIZE_TO_WIDTH end @width = widths.fetch(type.size) do raise(NotImplementedError,"type #{type} with unsupported size #{type.size}") end case type when Type::Float super("% #{@width}g"); @width += 1 else if type.signed? super("% #{@width}d"); @width += 1 else super("%#{@width}d") end end end