@@ -46,17 +46,19 @@ module Header
46
46
47
47
# Serializes the header value into the buffer
48
48
#
49
- # @param buffer [String] Buffer to receive the serialized value.
50
- # @param value [String] Header value to be serialized.
51
- # @return [String] Buffer with serialized value.
49
+ # @param buffer [ String ] Buffer to receive the serialized value.
50
+ # @param value [ String ] Header value to be serialized.
51
+ #
52
+ # @return [ String ] Buffer with serialized value.
52
53
def self . serialize ( buffer , value )
53
54
buffer . put_bytes ( value . pack ( HEADER_PACK ) )
54
55
end
55
56
56
57
# Deserializes the header value from the IO stream
57
58
#
58
- # @param io [IO] IO stream containing the message header.
59
- # @return [Array<Fixnum>] Array consisting of the deserialized
59
+ # @param [ String ] buffer Buffer containing the message header.
60
+ #
61
+ # @return [ Array<Fixnum> ] Array consisting of the deserialized
60
62
# length, request id, response id, and op code.
61
63
def self . deserialize ( buffer )
62
64
buffer . get_bytes ( 16 ) . unpack ( HEADER_PACK )
@@ -70,9 +72,10 @@ module CString
70
72
71
73
# Serializes a C style string into the buffer
72
74
#
73
- # @param buffer [String] Buffer to receive the serialized CString.
74
- # @param value [String] The string to be serialized.
75
- # @return [String] Buffer with serialized value.
75
+ # @param buffer [ String ] Buffer to receive the serialized CString.
76
+ # @param value [ String ] The string to be serialized.
77
+ #
78
+ # @return [ String ] Buffer with serialized value.
76
79
def self . serialize ( buffer , value )
77
80
buffer . put_cstring ( value )
78
81
end
@@ -85,9 +88,10 @@ module Zero
85
88
86
89
# Serializes a 32-bit Zero into the buffer
87
90
#
88
- # @param buffer [String] Buffer to receive the serialized Zero.
89
- # @param value [Fixnum] Ignored value.
90
- # @return [String] Buffer with serialized value.
91
+ # @param buffer [ String ] Buffer to receive the serialized Zero.
92
+ # @param value [ Fixnum ] Ignored value.
93
+ #
94
+ # @return [ String ] Buffer with serialized value.
91
95
def self . serialize ( buffer , value )
92
96
buffer . put_int32 ( ZERO )
93
97
end
@@ -100,17 +104,19 @@ module Int32
100
104
101
105
# Serializes a fixnum to a 4-byte 32-bit integer
102
106
#
103
- # @param buffer [String] Buffer to receive the serialized Int32.
104
- # @param value [Fixnum] 32-bit integer to be serialized.
107
+ # @param buffer [ String ] Buffer to receive the serialized Int32.
108
+ # @param value [ Fixnum ] 32-bit integer to be serialized.
109
+ #
105
110
# @return [String] Buffer with serialized value.
106
111
def self . serialize ( buffer , value )
107
112
buffer . put_int32 ( value )
108
113
end
109
114
110
115
# Deserializes a 32-bit Fixnum from the IO stream
111
116
#
112
- # @param io [IO] IO stream containing the 32-bit integer
113
- # @return [Fixnum] Deserialized Int32
117
+ # @param [ String ] buffer Buffer containing the 32-bit integer
118
+ #
119
+ # @return [ Fixnum ] Deserialized Int32
114
120
def self . deserialize ( buffer )
115
121
buffer . get_int32
116
122
end
@@ -123,16 +129,18 @@ module Int64
123
129
124
130
# Serializes a fixnum to an 8-byte 64-bit integer
125
131
#
126
- # @param buffer [String] Buffer to receive the serialized Int64.
127
- # @param value [Fixnum] 64-bit integer to be serialized.
128
- # @return [String] Buffer with serialized value.
132
+ # @param buffer [ String ] Buffer to receive the serialized Int64.
133
+ # @param value [ Fixnum ] 64-bit integer to be serialized.
134
+ #
135
+ # @return [ String ] Buffer with serialized value.
129
136
def self . serialize ( buffer , value )
130
137
buffer . put_int64 ( value )
131
138
end
132
139
133
140
# Deserializes a 64-bit Fixnum from the IO stream
134
141
#
135
- # @param io [IO] IO stream containing the 64-bit integer.
142
+ # @param [ String ] buffer Buffer containing the 64-bit integer.
143
+ #
136
144
# @return [Fixnum] Deserialized Int64.
137
145
def self . deserialize ( buffer )
138
146
buffer . get_int64
@@ -146,9 +154,10 @@ module Document
146
154
147
155
# Serializes a document into the buffer
148
156
#
149
- # @param buffer [String] Buffer to receive the BSON encoded document.
150
- # @param value [Hash] Document to serialize as BSON.
151
- # @return [String] Buffer with serialized value.
157
+ # @param buffer [ String ] Buffer to receive the BSON encoded document.
158
+ # @param value [ Hash ] Document to serialize as BSON.
159
+ #
160
+ # @return [ String ] Buffer with serialized value.
152
161
def self . serialize ( buffer , value , max_bson_size = nil )
153
162
start_size = buffer . length
154
163
value . to_bson ( buffer )
@@ -159,8 +168,9 @@ def self.serialize(buffer, value, max_bson_size = nil)
159
168
160
169
# Deserializes a document from the IO stream
161
170
#
162
- # @param io [IO] IO stream containing the BSON encoded document.
163
- # @return [Hash] The decoded BSON document.
171
+ # @param [ String ] buffer Buffer containing the BSON encoded document.
172
+ #
173
+ # @return [ Hash ] The decoded BSON document.
164
174
def self . deserialize ( buffer )
165
175
BSON ::Document . from_bson ( buffer )
166
176
end
0 commit comments