I'd like to know how to make structs using a class. I know this sounds a bit abstract, but this is what I'd like to achieve:
class Person < StructHelper
string :name
string :last_name
int :age
long :birth_date
def handle()
puts "My name is #{name} and I'm #{age} years old"
end
end
It could be useful in binary serialization.
Please note that Marshall cannot be used because the binary format I use is very specific (ie: int is 4bytes, long is 8bytes, string is 4bytes[len]+the string itself, etc), that is why I use a class.
It kind of is the same as BinData::Structure but I'd like it to be simpler than what BinData provides and I'd like to understand how it works.
Kind regards