Class: Rex::Poly::Permutation

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/poly/block.rb

Overview

This class encapsulates a LogicalBlock permutation. Block permutations can take the form of a static string or a procedure. This makes it possible to have simple blocks and more complicated ones that take into account other variables, such as dynamic registers. The to_s method will return the string version of the permutation, regardless of whether or not the underlying permutation is a string or a procedure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(perm, block) ⇒ Permutation

Initializes the permutation and its associated block.


20
21
22
23
# File 'lib/rex/poly/block.rb', line 20

def initialize(perm, block)
  @perm  = perm
  @block = block
end

Instance Attribute Details

#permObject (readonly)

Returns the value of attribute perm


45
46
47
# File 'lib/rex/poly/block.rb', line 45

def perm
  @perm
end

Instance Method Details

#lengthObject

Returns the length of the string returned by to_s.


28
29
30
# File 'lib/rex/poly/block.rb', line 28

def length
  to_s.length
end

#to_sObject

Returns the string representation of the permutation. If the underlying permutation is a procedure, the procedure is called. Otherwise, the string representation of the permutation is returned.


37
38
39
40
41
42
43
# File 'lib/rex/poly/block.rb', line 37

def to_s
  if (@perm.kind_of?(Proc))
    @perm.call(@block).to_s
  else
    @perm.to_s
  end
end