Module: Base85::Z85
- Extended by:
- ModuleMethods
- Defined in:
- lib/base85/z85.rb
Overview
ZeroMQ (Z85) encoding
Constant Summary collapse
- ALPHABET =
Z85 alphabet
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
Constants included from ModuleMethods
Class Method Summary collapse
-
.decode_char(char) ⇒ Integer
Decode a character from Z85 and give its index in alphabet.
-
.encode_value(value) ⇒ String
Encode a value (0..84 integer) to a Z85 character.
Methods included from ModuleMethods
Class Method Details
.decode_char(char) ⇒ Integer
Decode a character from Z85 and give its index in alphabet
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/base85/z85.rb', line 22 def self.decode_char(char) case char when "0".."9" char.ord - 48 when "a".."z" char.ord - 87 # - 97 + 10 when "A".."Z" char.ord - 29 # - 65 + 26 when "!", "#".."&", "(".."+", "-".."/", ":", "<".."@", "[", "]", "^", "{".."}" ALPHABET.index(char) else raise DecodeError, "unknown character '#{char}'" end end |
.encode_value(value) ⇒ String
Encode a value (0..84 integer) to a Z85 character
14 15 16 |
# File 'lib/base85/z85.rb', line 14 def self.encode_value(value) ALPHABET[value] end |