lib/bindata/base.rb in bindata-1.8.3 vs lib/bindata/base.rb in bindata-2.0.0

- old
+ new

@@ -231,21 +231,20 @@ else "obj" end end - # Returns the offset (in bytes) of this object with respect to its most - # distant ancestor. - def abs_offset + # Returns the offset of this object wrt to its most distant ancestor. + def offset if @parent - @parent.abs_offset + @parent.offset_of(self) + @parent.offset + @parent.offset_of(self) else 0 end end - # Returns the offset (in bytes) of this object with respect to its parent. + # Returns the offset of this object wrt to its parent. def rel_offset if @parent @parent.offset_of(self) else 0 @@ -280,13 +279,9 @@ an end end def binary_string(str) - if str.respond_to?(:force_encoding) - str.to_s.dup.force_encoding(Encoding::BINARY) - else - str.dup - end + str.to_s.dup.force_encoding(Encoding::BINARY) end end end