Class: Hexdump::Numeric::Hexadecimal Private
- Inherits:
-
FormatString
- Object
- FormatString
- Hexdump::Numeric::Hexadecimal
- Defined in:
- lib/hexdump/numeric/hexadecimal.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
- INT_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 => 2, # 0xff.to_s(16).length 2 => 4, # 0xffff.to_s(16).length 4 => 8, # 0xffffffff.to_s(16).length 8 => 16 # 0xffffffffffffffff.to_s(16).length }
- FLOAT_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.
20
Instance Attribute Summary collapse
- #width ⇒ Integer readonly private
Instance Method Summary collapse
-
#initialize(type) ⇒ Hexadecimal
constructor
private
Initializes the hexadecimal format.
Methods inherited from FormatString
Constructor Details
#initialize(type) ⇒ Hexadecimal
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 hexadecimal format.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 |
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.
22 23 24 |
# File 'lib/hexdump/numeric/hexadecimal.rb', line 22 def width @width end |