Module: Bases

Defined in:
lib/bases.rb,
lib/bases/version.rb,
lib/bases/constants.rb

Overview

The main module.

Defined Under Namespace

Modules: Algorithms, Helpers Classes: Number

Constant Summary collapse

VERSION =

The version of the Bases gem.

'1.0.2'
B62 =

Base 62, the alphanumeric characters.

(
  ('A'..'Z').to_a +
  ('a'..'z').to_a +
  (0..9).to_a
).map(&:to_s)
B64 =

Base 64.

B62 + %w(+ /)
InvalidValueError =

This error is thrown when an invalid value is passed to Number's constructor.

Class.new(StandardError)
NoBaseSpecifiedError =

This error is thrown when you try to convert a number without a specified base to another base.

Class.new(StandardError)
WrongDigitsError =

This error is thrown when there are digits in a value which aren't in the specified source base.

Class.new(StandardError)
DuplicateDigitsError =

This error is thrown when there are duplicates digits in a base.

Examples:

bad_base_3 = [0, 1, 0]
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.val(value) ⇒ Number Also known as: []

Create a new instance of Number from value.



17
18
19
# File 'lib/bases.rb', line 17

def self.val(value)
  Bases::Number.new(value)
end