Sha256: 5a9f887ec0b19e548721229d9be4ba351105b7f235b0f7dc9eb2fc232b00caf8
Contents?: true
Size: 1.32 KB
Versions: 43
Compression:
Stored size: 1.32 KB
Contents
#!/usr/bin/env ruby # Rex::Struct2 module Rex module Struct2 class Restraint attr_reader :max_object, :min_object, :should_update, :max_transform, :min_transform, :max_inv_transform, :min_inv_transform attr_writer :max_object, :min_object, :should_update, :max_transform, :min_transform, :max_inv_transform, :min_inv_transform def initialize( max_object=nil, min_object=nil, should_update=false, max_transform=nil, min_transform=nil, max_inv_transform=nil, min_inv_transform=nil ) @max_object = max_object @min_object = min_object @should_update = should_update def_trans = proc {|i| i} @max_transform = max_transform == nil ? def_trans : max_transform @min_transform = min_transform == nil ? def_trans : min_transform @max_inv_transform = max_inv_transform == nil ? def_trans : max_inv_transform @min_inv_transform = min_inv_transform == nil ? def_trans : min_inv_transform end def min return if !min_object return min_object.value end def max return if !max_object return max_object.value end # update values if request (ie string set field to its length) def update(value) return if !@should_update max_object.value = max_inv_transform.call(value) if max_object min_object.value = min_inv_transform.call(value) if min_object end end # end Rex::Struct2 end end
Version data entries
43 entries across 43 versions & 1 rubygems