deltacoding 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/lib/deltacoding.rb +29 -0
 - metadata +43 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 894787f128999925d4281033bd54575f95be845b02144da911f21786bd4ea425
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 76a484079f4f8e9b0be465ac740dbc6551681f3e475fcc325c879867e408b6d3
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fa9b94b0f3e15b7fd1ef8ae49a62c452a9c1a9fedb7e5ae9139b8cfb22cce18d37a5a4a8cea9af97d3aebc5c687a9756985c033d1ccfc0cf9945dbcaeb5d2391
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1b8e00c08f502654d128285d29e262641dda9c4b57cbf5aa007368f34d830723b758688d4caededa1530f06768358dfd4949767e6409aab796364dd76bb5357a
         
     | 
    
        data/lib/deltacoding.rb
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Delta
         
     | 
| 
      
 4 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 5 
     | 
    
         
            +
                def encode(array_of_digits)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  array_of_digits.map.with_index do |elem, index|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    next elem if index.zero?
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    elem - array_of_digits[index - 1]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def decode(array_of_digits)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  array_of_digits.each.with_index.each_with_object([]) do |(elem, index), arr|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    next arr << elem if index.zero?
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    arr << elem + arr[index - 1]
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def asci_encode(string)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  encode(string.split('').map(&:ord))
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def asci_decode(array_of_digits)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  decode(array_of_digits).map { |e| e.chr(Encoding::UTF_8) }.join
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: deltacoding
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - HolyWalley
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-06-11 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            email: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 16 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 17 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 18 
     | 
    
         
            +
            files:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - lib/deltacoding.rb
         
     | 
| 
      
 20 
     | 
    
         
            +
            homepage: https://github.com/HolyWalley/deltacoding
         
     | 
| 
      
 21 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 22 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 23 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 24 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 26 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 27 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 28 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 30 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 31 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 33 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 34 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 35 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 36 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 37 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 38 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 39 
     | 
    
         
            +
            rubygems_version: 3.0.3
         
     | 
| 
      
 40 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 41 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 42 
     | 
    
         
            +
            summary: Small gem to encode/decode using delta encoding
         
     | 
| 
      
 43 
     | 
    
         
            +
            test_files: []
         
     |