Module: Rex::Struct2::Element

Included in:
CStruct, Constant, Generic, SString, SStruct
Defined in:
lib/rex/struct2/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#containerObject

elements should have to_s, but we don’t define it here because it will just overlap with inheritence and cause issues



13
14
15
# File 'lib/rex/struct2/element.rb', line 13

def container
  @container
end

#restraintObject

elements should have to_s, but we don’t define it here because it will just overlap with inheritence and cause issues



13
14
15
# File 'lib/rex/struct2/element.rb', line 13

def restraint
  @restraint
end

#valueObject

elements should have to_s, but we don’t define it here because it will just overlap with inheritence and cause issues



13
14
15
# File 'lib/rex/struct2/element.rb', line 13

def value
  @value
end

Instance Method Details

#slengthObject

avoid conflicting with normal namespace length()



23
24
25
# File 'lib/rex/struct2/element.rb', line 23

def slength
	to_s().length()
end

#update_restraintObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rex/struct2/element.rb', line 27

def update_restraint
	if self.restraint
		# Sort of a hack, but remove the restraint before we update, so we aren't using
		# the old restraint during calculating the restraint update value
		old_restraint, self.restraint = self.restraint, nil
		old_restraint.update(self.slength)
		self.restraint = old_restraint
	end

	if self.container
		self.container.update_restraint
	end
end