Class: Rex::Struct2::Restraint
- Inherits:
-
Object
- Object
- Rex::Struct2::Restraint
- Defined in:
- lib/rex/struct2/restraint.rb
Instance Attribute Summary collapse
-
#max_inv_transform ⇒ Object
Returns the value of attribute max_inv_transform.
-
#max_object ⇒ Object
Returns the value of attribute max_object.
-
#max_transform ⇒ Object
Returns the value of attribute max_transform.
-
#min_inv_transform ⇒ Object
Returns the value of attribute min_inv_transform.
-
#min_object ⇒ Object
Returns the value of attribute min_object.
-
#min_transform ⇒ Object
Returns the value of attribute min_transform.
-
#should_update ⇒ Object
Returns the value of attribute should_update.
Instance Method Summary collapse
-
#initialize(max_object = nil, min_object = nil, should_update = false, max_transform = nil, min_transform = nil, max_inv_transform = nil, min_inv_transform = nil) ⇒ Restraint
constructor
A new instance of Restraint.
- #max ⇒ Object
- #min ⇒ Object
-
#update(value) ⇒ Object
update values if request (ie string set field to its length).
Constructor Details
#initialize(max_object = nil, min_object = nil, should_update = false, max_transform = nil, min_transform = nil, max_inv_transform = nil, min_inv_transform = nil) ⇒ Restraint
Returns a new instance of Restraint.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rex/struct2/restraint.rb', line 15 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 |
Instance Attribute Details
#max_inv_transform ⇒ Object
Returns the value of attribute max_inv_transform.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def max_inv_transform @max_inv_transform end |
#max_object ⇒ Object
Returns the value of attribute max_object.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def max_object @max_object end |
#max_transform ⇒ Object
Returns the value of attribute max_transform.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def max_transform @max_transform end |
#min_inv_transform ⇒ Object
Returns the value of attribute min_inv_transform.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def min_inv_transform @min_inv_transform end |
#min_object ⇒ Object
Returns the value of attribute min_object.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def min_object @min_object end |
#min_transform ⇒ Object
Returns the value of attribute min_transform.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def min_transform @min_transform end |
#should_update ⇒ Object
Returns the value of attribute should_update.
9 10 11 |
# File 'lib/rex/struct2/restraint.rb', line 9 def should_update @should_update end |
Instance Method Details
#max ⇒ Object
37 38 39 40 |
# File 'lib/rex/struct2/restraint.rb', line 37 def max return if !max_object return max_object.value end |
#min ⇒ Object
32 33 34 35 |
# File 'lib/rex/struct2/restraint.rb', line 32 def min return if !min_object return min_object.value end |
#update(value) ⇒ Object
update values if request (ie string set field to its length)
43 44 45 46 47 48 |
# File 'lib/rex/struct2/restraint.rb', line 43 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 |