Class: Hexdump::Numeric::Octal Private
- Inherits:
-
FormatString
- Object
- FormatString
- Hexdump::Numeric::Octal
- Defined in:
- lib/hexdump/numeric/octal.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- SIZE_TO_WIDTH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 1 => 3, # 0xff.to_s(7).length 2 => 6, # 0xffff.to_s(7).length 4 => 11, # 0xffffffff.to_s(7).length 8 => 22 # 0xffffffffffffffff.to_s(7).length }
Instance Attribute Summary collapse
- #width ⇒ Integer readonly private
Instance Method Summary collapse
-
#initialize(type) ⇒ Octal
constructor
private
Initializes the octal format.
Methods inherited from FormatString
Constructor Details
#initialize(type) ⇒ Octal
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the octal format.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 |
Instance Attribute Details
#width ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/hexdump/numeric/octal.rb', line 21 def width @width end |