X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=lib%2Feet.rb;h=8a949845063a5baf1ef8e0c75fa3ec7b9741dcfa;hb=49e6c8f56d89681f20836a14480959fa89d24e26;hp=16cf90fbbdf06ec710f98dae8388a2bbcb913da8;hpb=b50b7eda959639a4c5c213495899e8d03ee15599;p=ruby-eet.git diff --git a/lib/eet.rb b/lib/eet.rb index 16cf90f..8a94984 100644 --- a/lib/eet.rb +++ b/lib/eet.rb @@ -1,5 +1,5 @@ #-- -# $Id: eet.rb 19 2005-03-29 17:02:30Z tilman $ +# $Id: eet.rb 34 2005-04-30 13:15:19Z tilman $ # # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # @@ -154,7 +154,7 @@ class Hash # :nodoc: end module Eet - VERSION = "0.1.1" + VERSION = "0.1.2" class EetError < StandardError; end class NameError < EetError; end @@ -166,10 +166,6 @@ module Eet super(chunk.nil? ? 0 : 1, chunk) end - def serialize - inject("") { |a, c| a << c.serialize } - end - def Stream.deserialize(data) data = data.to_str.dup s = Stream.new @@ -194,21 +190,13 @@ module Eet @tag = tag.to_str.dup.freeze @data = data.to_str.dup.freeze - @size = @tag.length + 1 + @data.length - # libeet uses a signed 32bit integer to store the # chunk size, so make sure we don't overflow it - if @size >= (1 << 31) + if (@tag.length + 1 + @data.length) >= (1 << 31) raise(ArgumentError, "tag or data too long") end end - def serialize - buf = "CHnK" - buf << [@size].pack("V") - buf << @tag << "\0" << @data - end - def Chunk.deserialize(data) if data.length < 8 || data[0, 4] != "CHnK" raise(ChunkError, "invalid data")