Method: Rex::Struct2::Generic#from_s
- Defined in:
- lib/rex/struct2/generic.rb
#from_s(bytes) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rex/struct2/generic.rb', line 51 def from_s(bytes) value = bytes.unpack(@packspec)[0] # return nil on unpack error return if !value len = slength() # error on any restraint issues return if restraint && restraint.max && len > restraint.max return if restraint && restraint.min && len < restraint.min # else set our value and return length used for this element if (value & check_mask) != 0 value = -((~value & mask) + 1) end self.value = value return(len) end |