Sha256: 6b01f98c5926dc5fe072c40814cff2ec547b5eafa2d4fcdc394fca782d994094

Contents?: true

Size: 549 Bytes

Versions: 4

Compression:

Stored size: 549 Bytes

Contents

require 'scrambled_jpeg/version'
module ScrambledJpeg
  class << self
    def scramble filename, grain
      ending, cache = (store = File.readlines filename).pop, []
      (new_file = File.open Time.now.hash.to_s + '.jpg', "w").write store.shift
      (grain || 5).times { new_file.write store.shift }
           .times {       cache << store.shift }
           .times { new_file.write store.shift }
           .times { new_file.write cache.shift } until store.empty? && cache.empty?
      new_file.write ending && new_file.close
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scrambled_jpeg-0.1.5 lib/scrambled_jpeg.rb
scrambled_jpeg-0.1.2 lib/scrambled_jpeg.rb
scrambled_jpeg-0.1.1 lib/scrambled_jpeg.rb
scrambled_jpeg-0.1.0 lib/scrambled_jpeg.rb