lib/packetgen/structfu.rb in packetgen-0.3.0 vs lib/packetgen/structfu.rb in packetgen-1.0.0

- old
+ new

@@ -1,12 +1,12 @@ -# -*- coding: binary -*- +# -*- coding: utf-8 -*- module PacketGen + # Copied from PacketFu: + # # StructFu, a nifty way to leverage Ruby's built in Struct class # to create meaningful binary data. # - # Copied from PacketFu: - # # Copyright (c) 2008-2014, Tod Beardsley # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -28,10 +28,11 @@ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # @author Tod Beardsley module StructFu # Normally, self.size and self.length will refer to the Struct # size as an array. It's a hassle to redefine, so this introduces some # shorthand to get at the size of the resultant string. @@ -80,9 +81,10 @@ e end # Get binary string # @return [String] + # @author Sylvain Daubert def to_s to_a.map { |field| field.to_s }.join end # Ints all have a value, an endianness, and a default value.