Class: Ciphr::Functions::Base::Base16

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



68
69
70
# File 'lib/ciphr/functions/base_radix.rb', line 68

def self.params
  [:input]
end

.variantsObject



64
65
66
# File 'lib/ciphr/functions/base_radix.rb', line 64

def self.variants
  [[['b16','base16','hex','hexidecimal'], {}]]
end

Instance Method Details

#applyObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ciphr/functions/base_radix.rb', line 72

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