README in bindata-0.7.0 vs README in bindata-0.8.0

- old
+ new

@@ -15,11 +15,11 @@ It's ugly, violates DRY and feels like you're writing Perl, not Ruby. There is a better way. class Rectangle < BinData::Struct uint16le :len - string :name, :initial_length => :len + string :name, :read_length => :len uint32le :width uint32le :height end io = File.open(...) @@ -100,11 +100,11 @@ Here's how we'd implement the same example with BinData. class PascalString < BinData::Struct uint8 :len, :value => lambda { data.length } - string :data, :initial_length => :len + string :data, :read_length => :len end # reading io = File.open(...) ps = PascalString.new @@ -120,18 +120,18 @@ This syntax needs explaining. Let's simplify by examining reading and writing separately. class PascalStringReader < BinData::Struct uint8 :len - string :data, :initial_length => :len + string :data, :read_length => :len end This states that when reading the string, the initial length of the string (and hence the number of bytes to read) is determined by the value of the +len+ field. -Note that <tt>:initial_length => :len</tt> is syntactic sugar for -<tt>:initial_length => lambda { len }</tt>, but more on that later. +Note that <tt>:read_length => :len</tt> is syntactic sugar for +<tt>:read_length => lambda { len }</tt>, but more on that later. class PascalStringWriter < BinData::Struct uint8 :len, :value => lambda { data.length } string :data end