Module: LZString
- Defined in:
- lib/lz_string.rb,
lib/lz_string/base.rb,
lib/lz_string/utf16.rb,
lib/lz_string/base64.rb,
lib/lz_string/urisafe.rb,
lib/lz_string/version.rb
Overview
LZ-based compression algorithm.
Defined Under Namespace
Classes: Base, Base64, UTF16, UriSafe
Constant Summary collapse
- VERSION =
:nodoc:
"0.2.0"
Class Method Summary collapse
Class Method Details
.compress(input) ⇒ Object
10 11 12 13 14 |
# File 'lib/lz_string.rb', line 10 def self.compress(input) return "" if input.nil? LZString::Base.compress(input, 16, lambda { |a| a.chr("UTF-8") }) end |
.decompress(compressed) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/lz_string.rb', line 17 def self.decompress(compressed) return "" if compressed.nil? return nil if compressed == "" LZString::Base.decompress(compressed.length, 32768, lambda { |index| compressed[index].ord }) end |