# File lib/rex/struct2/s_string.rb, line 52 def from_s(bytes) # we don't have enough bytes to satisfy our minimum if restraint && restraint.min && bytes.length < restraint.min return end if restraint && restraint.max self.value = bytes.slice(0, restraint.max) else self.value = bytes.dup end return(self.slength) end
# File lib/rex/struct2/s_string.rb, line 31 def reset self.value = @default end
# File lib/rex/struct2/s_string.rb, line 22 def size=(newsize) if !newsize self.restraint = nil else res = Rex::Struct2::Constant.new(newsize) self.restraint = Rex::Struct2::Restraint.new(res, res, false) end end
# File lib/rex/struct2/s_string.rb, line 35 def to_s string = self.value return if !string # pad if short if restraint && restraint.min && self.pad && restraint.min > string.length string += self.pad * (restraint.min - string.length) end # truncate if long if restraint && restraint.max string = string.slice(0, restraint.max) end return string end
Generated with the Darkfish Rdoc Generator 2.