Class: BentleyMcIlroy::Codec
- Inherits:
-
Object
- Object
- BentleyMcIlroy::Codec
- Defined in:
- lib/bentley_mcilroy.rb
Class Method Summary collapse
- .compress(text, block_size) ⇒ Object
- .decode(source, delta) ⇒ Object
- .decompress(sequence) ⇒ Object
- .encode(source, target, block_size) ⇒ Object
Class Method Details
.compress(text, block_size) ⇒ Object
156 157 158 |
# File 'lib/bentley_mcilroy.rb', line 156 def self.compress(text, block_size) __compress_encode__(text, nil, block_size) end |
.decode(source, delta) ⇒ Object
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/bentley_mcilroy.rb', line 145 def self.decode(source, delta) delta.inject("") do |result, i| if i.is_a?(Array) index, length = i result << source[index, length] else result << i end end end |
.decompress(sequence) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/bentley_mcilroy.rb', line 131 def self.decompress(sequence) sequence.inject("") do |result, i| if i.is_a?(Array) index, length = i length.times do |k| result << result[index+k, 1] end result else result << i end end end |
.encode(source, target, block_size) ⇒ Object
160 161 162 |
# File 'lib/bentley_mcilroy.rb', line 160 def self.encode(source, target, block_size) __compress_encode__(source, target, block_size) end |