Class: Plurimath::Formatter::Numbers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/plurimath/formatter/numbers/base.rb

Overview

Shared base for formatter helpers that need resolved options, target base state, and common digit operations.

Direct Known Subclasses

Fraction, Integer, Significant

Constant Summary collapse

HEX_DIGITS =
"abcdef"
HEX_ALPHANUMERIC =
%w[0 1 2 3 4 5 6 7 8 9 a b c d e f].freeze
DEFAULT_BASE =
10
DIGIT_VALUE =
HEX_ALPHANUMERIC.each_with_index.to_h

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



16
17
18
19
# File 'lib/plurimath/formatter/numbers/base.rb', line 16

def initialize(options)
  @options = options
  @base = @options.base
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



14
15
16
# File 'lib/plurimath/formatter/numbers/base.rb', line 14

def base
  @base
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/plurimath/formatter/numbers/base.rb', line 14

def options
  @options
end