Created
March 14, 2012 16:50
-
-
Save meltingice/2037813 to your computer and use it in GitHub Desktop.
Example port of Ruby's BinData to Coffeescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rectangle extends BinData.Record | |
endian: "little" | |
parse: -> | |
uint16 "len" | |
string "name", readLength: len | |
uint32 "width" | |
uint32 "height" | |
r = new Rectangle(file) | |
console.log "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
Yeah, I ended up creating a "data" class for some of the resources. Here's mine for the header: