Ints all have a value, an endianness, and a default value. Note that the signedness of Int values are implicit as far as the subclasses are concerned; to_i and to_f will return Integer/Float versions of the input value, instead of attempting to unpack the pack value. (This can be a useful hint to other functions).
Fixnum :value Symbol :endian Fixnum :width Fixnum :default
Reads either an Integer or a packed string, and populates the value accordingly.
# File lib/packetfu/structfu.rb, line 88 def read(i) self.v = i.kind_of?(Integer) ? i.to_i : i.to_s.unpack(@packstr).first self end
Returns the Int as a Float.
# File lib/packetfu/structfu.rb, line 79 def to_f (self.v || self.d).to_f end
Returns the Int as an Integer.
# File lib/packetfu/structfu.rb, line 74 def to_i (self.v || self.d).to_i end
Generated with the Darkfish Rdoc Generator 2.