Class: Ciphr::Functions::Base::Base16
- Inherits:
-
Base
show all
- Defined in:
- lib/ciphr/functions/base_radix.rb
Instance Attribute Summary
#invert
Attributes inherited from Function
#args, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
aligned
invertable?
Methods inherited from Function
aligned, inherited, #initialize, invertable?, #prepend, #read
Class Method Details
.params ⇒ Object
68
69
70
|
# File 'lib/ciphr/functions/base_radix.rb', line 68
def self.params
[:input]
end
|
.variants ⇒ Object
64
65
66
|
# File 'lib/ciphr/functions/base_radix.rb', line 64
def self.variants
[[['b16','base16','hex','hexidecimal'], {}]]
end
|
Instance Method Details
#apply ⇒ Object
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
|