Class: BaseN::Number

Inherits:
Struct
  • Object
show all
Defined in:
lib/base_n.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#baseObject

Returns the value of attribute base

Returns:

  • (Object)

    the current value of base



4
5
6
# File 'lib/base_n.rb', line 4

def base
  @base
end

#representationObject

Returns the value of attribute representation

Returns:

  • (Object)

    the current value of representation



4
5
6
# File 'lib/base_n.rb', line 4

def representation
  @representation
end

Instance Method Details

#rebase(new_base) ⇒ Object



13
14
15
# File 'lib/base_n.rb', line 13

def rebase new_base
  Encoder.new(new_base).encode to_i
end

#to_iObject



9
10
11
# File 'lib/base_n.rb', line 9

def to_i
  Encoder.new(base).decode self
end

#to_sObject



5
6
7
# File 'lib/base_n.rb', line 5

def to_s
  representation
end