Module: Base85::Standard
- Extended by:
- ModuleMethods
- Defined in:
- lib/base85/standard.rb
Overview
Standard base85 encoding. This encoding uses ! to u ASCII characters to encode data.
Constant Summary collapse
- BASE_ASCII_VALUE =
ASCII value for character !
"!".ord
Constants included from ModuleMethods
Class Method Summary collapse
-
.decode_char(char) ⇒ Integer
Decode a character from standard base85 and give its index in alphabet.
-
.encode_value(value) ⇒ String
Encode a value (0..84 integer) to a standard base85 character.
Methods included from ModuleMethods
Class Method Details
.decode_char(char) ⇒ Integer
Decode a character from standard base85 and give its index in alphabet
23 24 25 26 27 28 29 30 |
# File 'lib/base85/standard.rb', line 23 def self.decode_char(char) case char when "!".."u" # rubocop:disable Lint/MixedCaseRange char.ord - BASE_ASCII_VALUE else raise DecodeError, "unknown character '#{char}'" end end |
.encode_value(value) ⇒ String
Encode a value (0..84 integer) to a standard base85 character
15 16 17 |
# File 'lib/base85/standard.rb', line 15 def self.encode_value(value) (BASE_ASCII_VALUE + value).chr end |