Module: Blurhash::Base83

Defined in:
lib/blurhash.rb

Constant Summary collapse

DIGIT_CHARACTERS =
%w(
  0 1 2 3 4 5 6 7 8 9
  A B C D E F G H I J
  K L M N O P Q R S T
  U V W X Y Z a b c d
  e f g h i j k l m n
  o p q r s t u v w x
  y z # $ % * + , - .
  : ; = ? @ [ ] ^ _ {
  | } ~
).freeze

Class Method Summary collapse

Class Method Details

.decode83(str) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/blurhash.rb', line 37

def self.decode83(str)
  value = 0

  str.each_char.with_index do |c, i|
    digit = DIGIT_CHARACTERS.find_index(c)
    value = value * 83 + digit
  end

  value
end