Class: Ciphr::Functions::Base::Base32

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



99
100
101
# File 'lib/ciphr/functions/base_radix.rb', line 99

def self.params
  [:input]
end

.variantsObject



90
91
92
93
94
95
96
97
# File 'lib/ciphr/functions/base_radix.rb', line 90

def self.variants
  [
    [['b32','base32','b32-std','base32-std'], {:object => ::Base32 }]#, 
    #broken
    #[['b32-crockford','base32-crockford'], {:object => ::Base32::Crockford }],
    #[['b32-z','base32-z'], {:object => ZBase32.new }]
  ]
end

Instance Method Details

#applyObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/ciphr/functions/base_radix.rb', line 103

def apply
  input = @args[0]
  if !invert              
    Proc.new do
      chunk = input.read(5)
      chunk && options[:object].encode(chunk)
    end
  else
    Proc.new do
      chunk = input.read(8)
      chunk && options[:object].decode(chunk)
    end
  end
end