Class: Ciphr::Functions::Simple::Translate

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



73
74
75
# File 'lib/ciphr/functions/simple.rb', line 73

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

.variantsObject



69
70
71
# File 'lib/ciphr/functions/simple.rb', line 69

def self.variants
  [ [['tr','translate'], {}] ]
end

Instance Method Details

#applyObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ciphr/functions/simple.rb', line 56

def apply
  input, ch1in, ch2in = @args
  ch1, ch2 = [ch1in.read, ch2in.read]
  Proc.new do
    inchunk = input.read(1)
    if inchunk
      inchunk.tr(ch1, ch2)
    else
      nil
    end
  end
end