Class: Ciphr::Functions::Bitwise::UnaryBitwise

Inherits:
Function
  • Object
show all
Defined in:
lib/ciphr/functions/bitwise.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



76
77
78
# File 'lib/ciphr/functions/bitwise.rb', line 76

def self.params
  [:input]
end

.variantsObject



72
73
74
# File 'lib/ciphr/functions/bitwise.rb', line 72

def self.variants
  [ ['not', {}] ]
end

Instance Method Details

#applyObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ciphr/functions/bitwise.rb', line 60

def apply
  input = @args[0]
  Proc.new do
    inchunk = input.read(1)
    if inchunk
      inchunk.bytes.map{|b| b = ~b }.pack("c*")
    else
      nil
    end
  end
end