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