Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created February 17, 2011 22:24
Show Gist options
  • Select an option

  • Save zeroeth/832865 to your computer and use it in GitHub Desktop.

Select an option

Save zeroeth/832865 to your computer and use it in GitHub Desktop.
class Rectangle < BinData::Record
endian :little
uint16 :len
string :name, :read_length => :len
uint32 :width
uint32 :height
end
io = File.open(...)
r = Rectangle.read(io)
puts "Rectangle #{r.name} is #{r.width} x #{r.height}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment