Class: Ciphr::Functions::Simple::Repack

Inherits:
Function
  • Object
show all
Defined in:
lib/ciphr/functions/simple.rb

Instance Attribute Summary

Attributes inherited from Function

#args, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

aligned, inherited, #initialize, invertable?, #prepend, #read

Constructor Details

This class inherits a constructor from Ciphr::Functions::Function

Class Method Details

.paramsObject



50
51
52
# File 'lib/ciphr/functions/simple.rb', line 50

def self.params
  [:input,:ch1,:ch2]
end

.variantsObject



46
47
48
# File 'lib/ciphr/functions/simple.rb', line 46

def self.variants
  [ [['repack'], {}] ]
end

Instance Method Details

#applyObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ciphr/functions/simple.rb', line 30

def apply
  input, ch1in, ch2in = @args
  content, ch1, ch2 = [input.read, ch1in.read, ch2in.read]
  Proc.new do
    if content
      begin
        content.unpack(ch1).pack(ch2)
      ensure
        content = nil
      end
    else
      nil
    end
  end
end