Re-implemented Object#to_eet in C.
[ruby-eet.git] / lib / eet.rb
index 194409e4df9cbe8bf191f86e2812ee7f0adb2459..3976032d12bf25852f925d6dca2e25eb61a1beb9 100644 (file)
@@ -1,5 +1,5 @@
 #--
-# $Id: eet.rb 47 2005-05-30 19:19:07Z tilman $
+# $Id: eet.rb 49 2005-05-30 19:52:36Z tilman $
 #
 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
 #
 require "eet_ext"
 
 class Object
-       # :call-seq:
-       #  object.to_eet -> string
-       #
-       # Serializes the receiver to EET format.
-       def to_eet
-               props = to_eet_properties
-
-               unless props.is_a?(Hash) && !props.empty?
-                       raise(Eet::PropertyError, "invalid EET properties")
-               end
-
-               eet_name = to_eet_name
-
-               if eet_name.to_str.length < 1 || eet_name.to_str.include?(0)
-                       raise(Eet::NameError, "invalid EET name")
-               end
-
-               stream = Eet::Stream.new
-
-               props.each_pair do |tag, arg|
-                       unless arg.is_a?(Array)
-                               raise(Eet::PropertyError, "hash value is not an array")
-                       end
-
-                       value, type = arg
-                       next if value.nil?
-
-                       stream.push(*value.to_eet_chunks(tag, type))
-               end
-
-               chunk = Eet::Chunk.new(eet_name, stream.serialize)
-               Eet::Stream.new(chunk).serialize
-       end
-
        def to_eet_chunks(tag, type = nil) # :nodoc:
                [Eet::Chunk.new(tag, to_eet)]
        end
@@ -156,9 +122,6 @@ end
 module Eet
        VERSION = "0.1.2"
 
-       class EetError < StandardError; end
-       class NameError < EetError; end
-       class PropertyError < EetError; end
        class ChunkError < EetError; end
 
        class Stream # :nodoc: