module Nuggets::Integer::MapMixin

Public Instance Methods

map_positive → anInteger click to toggle source

Creates a bijection from Z to N, i.e., it maps int to a positive integer.

# File lib/nuggets/integer/map_mixin.rb, line 36
def map_positive
  2 * abs + (self > 0 ? 0 : 1)
end