@@ -16,21 +16,25 @@ class Unpacker
1616 # @param io [IO]
1717 # @param options [Hash]
1818 # This unpacker reads data from the _io_ to fill the internal buffer.
19- # _io_ must respond to readpartial(length,string) or read(length,string) method.
19+ # _io_ must respond to readpartial(length[ ,string] ) or read(length[ ,string] ) method.
2020 #
2121 def initialize ( *args )
2222 end
2323
2424 #
2525 # Internal buffer
2626 #
27- # @return MessagePack::Unpacker
27+ # @return [ MessagePack::Unpacker]
2828 #
2929 attr_reader :buffer
3030
3131 #
3232 # Deserializes an object from internal buffer and returns it.
3333 #
34+ # If there're not enough buffer, this method raises EOFError.
35+ # If data format is invalid, this method raises MessagePack::MalformedFormatError.
36+ # If the stack is too deep, this method raises MessagePack::StackError.
37+ #
3438 # @return [Object] deserialized object
3539 #
3640 def read
@@ -41,25 +45,31 @@ def read
4145 #
4246 # Deserializes an object and ignores it. This method is faster than _read_.
4347 #
48+ # This method could raise same errors with _read_.
49+ #
4450 # @return nil
4551 #
4652 def skip
4753 end
4854
4955 #
5056 # Deserializes a nil value if it exists and returns _true_.
51- # Otherwise, if a byte exists but the byte is not nil value or the internal buffer is empty, returns _false_.
57+ # Otherwise, if a byte exists but the byte doesn't represent nil value,
58+ # returns _false_.
59+ #
60+ # If there're not enough buffer, this method raises EOFError.
5261 #
5362 # @return [Boolean]
5463 #
55- def skip
64+ def skip_nil
5665 end
5766
5867 #
5968 # Read a header of an array and returns its size.
6069 # It converts a serialized array into a stream of elements.
6170 #
6271 # If the serialized object is not an array, it raises MessagePack::TypeError.
72+ # If there're not enough buffer, this method raises EOFError.
6373 #
6474 # @return [Integer] size of the array
6575 #
@@ -71,6 +81,7 @@ def read_array_header
7181 # It converts a serialized map into a stream of key-value pairs.
7282 #
7383 # If the serialized object is not a map, it raises MessagePack::TypeError.
84+ # If there're not enough buffer, this method raises EOFError.
7485 #
7586 # @return [Integer] size of the map
7687 #
@@ -82,6 +93,7 @@ def read_map_header
8293 # This method calls buffer.append(data).
8394 #
8495 # @param data [String]
96+ # @return [Unpacker] self
8597 #
8698 def feed ( data )
8799 end
@@ -91,8 +103,10 @@ def feed(data)
91103 #
92104 # It repeats until the internal buffer does not include any complete objects.
93105 #
94- # If the internal IO was set, it reads data from the IO when the buffer becomes empty,
95- # and returns when the IO raised EOFError.
106+ # If the an IO is set, it repeats to read data from the IO when the buffer
107+ # becomes empty until the IO raises EOFError.
108+ #
109+ # This method could raise same errors with _read_ excepting EOFError.
96110 #
97111 # @yieldparam object [Object] deserialized object
98112 # @return nil
0 commit comments