Class: LZString::UriSafe

Inherits:
Object
  • Object
show all
Defined in:
lib/lz_string/urisafe.rb

Constant Summary collapse

KEY_STR_URISAFE =

Base64 alphabet.

"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$"

Class Method Summary collapse

Class Method Details

.compress(input) ⇒ Object

Parameters:

  • input (String)


7
8
9
10
11
# File 'lib/lz_string/urisafe.rb', line 7

def self.compress(input)
  return "" if input.nil?

  LZString::Base.compress(input, 6, lambda { |a| KEY_STR_URISAFE[a] })
end

.decompress(compressed) ⇒ Object

Parameters:

  • compressed (String)


14
15
16
17
18
19
20
21
22
23
# File 'lib/lz_string/urisafe.rb', line 14

def self.decompress(compressed)
  return "" if compressed.nil?
  return nil if compressed == ""
  compressed.gsub!(" ","+")
  LZString::Base.decompress(
    compressed.length,
    32,
    lambda { |index| get_base_value(KEY_STR_URISAFE, compressed[index]) }
  )
end