Class: Ciphr::Functions::Base::Base2

Inherits:
Base show all
Defined in:
lib/ciphr/functions/base_radix.rb

Instance Attribute Summary

Attributes inherited from InvertibleFunction

#invert

Attributes inherited from Function

#args, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aligned

Methods inherited from InvertibleFunction

invertable?

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



16
17
18
# File 'lib/ciphr/functions/base_radix.rb', line 16

def self.params
  [:input]
end

.variantsObject



12
13
14
# File 'lib/ciphr/functions/base_radix.rb', line 12

def self.variants
  [[['b2','base2', 'bin','binary'], {}]]
end

Instance Method Details

#applyObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ciphr/functions/base_radix.rb', line 20

def apply
  input = @args[0]
  if !invert              
    Proc.new do
      chunk = input.read(1)
      chunk && chunk.unpack("B*")[0]
    end
  else
    Proc.new do
      chunk = input.read(8)
      chunk && [chunk].pack("B*")
    end
  end
end