class Hexdump::Numeric::Octal
@api private
@since 1.0.0
Constants
- SIZE_TO_WIDTH
Attributes
width[R]
@return [Integer]
Public Class Methods
new(type)
click to toggle source
Initializes the octal format.
@param [Type::Int, Type::UInt] type
@raise [NotImplementedError]
@raise [IncompatibleTypeError]
@raise [TypeError]
Calls superclass method
Hexdump::FormatString::new
# File lib/hexdump/numeric/octal.rb, line 34 def initialize(type) case type when Type::Int, Type::UInt @width = SIZE_TO_WIDTH.fetch(type.size) do raise(NotImplementedError,"type #{type} with unsupported size #{type.size}") end if type.signed? super("% .#{@width}o"); @width += 1 else super("%.#{@width}o") end when Type::Float raise(IncompatibleTypeError,"cannot format floating-point numbers in octal") else raise(TypeError,"unsupported type: #{type.inspect}") end end