msgpack 1.3.3 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +99 -0
  3. data/README.md +293 -0
  4. data/ext/java/org/msgpack/jruby/Buffer.java +26 -19
  5. data/ext/java/org/msgpack/jruby/Decoder.java +46 -23
  6. data/ext/java/org/msgpack/jruby/Encoder.java +68 -30
  7. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +43 -64
  8. data/ext/java/org/msgpack/jruby/ExtensionValue.java +6 -9
  9. data/ext/java/org/msgpack/jruby/Factory.java +43 -42
  10. data/ext/java/org/msgpack/jruby/Packer.java +37 -40
  11. data/ext/java/org/msgpack/jruby/Unpacker.java +86 -68
  12. data/ext/msgpack/buffer.c +58 -85
  13. data/ext/msgpack/buffer.h +59 -20
  14. data/ext/msgpack/buffer_class.c +161 -52
  15. data/ext/msgpack/buffer_class.h +1 -0
  16. data/ext/msgpack/compat.h +1 -111
  17. data/ext/msgpack/extconf.rb +41 -23
  18. data/ext/msgpack/factory_class.c +143 -87
  19. data/ext/msgpack/packer.c +66 -43
  20. data/ext/msgpack/packer.h +25 -27
  21. data/ext/msgpack/packer_class.c +102 -130
  22. data/ext/msgpack/packer_class.h +11 -0
  23. data/ext/msgpack/packer_ext_registry.c +35 -40
  24. data/ext/msgpack/packer_ext_registry.h +41 -38
  25. data/ext/msgpack/rbinit.c +1 -1
  26. data/ext/msgpack/rmem.c +3 -4
  27. data/ext/msgpack/sysdep.h +5 -2
  28. data/ext/msgpack/unpacker.c +130 -126
  29. data/ext/msgpack/unpacker.h +22 -13
  30. data/ext/msgpack/unpacker_class.c +94 -124
  31. data/ext/msgpack/unpacker_class.h +11 -0
  32. data/ext/msgpack/unpacker_ext_registry.c +40 -28
  33. data/ext/msgpack/unpacker_ext_registry.h +21 -18
  34. data/lib/msgpack/bigint.rb +69 -0
  35. data/lib/msgpack/buffer.rb +9 -0
  36. data/lib/msgpack/factory.rb +140 -10
  37. data/lib/msgpack/packer.rb +10 -1
  38. data/lib/msgpack/symbol.rb +21 -4
  39. data/lib/msgpack/time.rb +1 -1
  40. data/lib/msgpack/unpacker.rb +14 -1
  41. data/lib/msgpack/version.rb +4 -8
  42. data/lib/msgpack.rb +7 -12
  43. data/msgpack.gemspec +9 -8
  44. metadata +37 -96
  45. data/.gitignore +0 -23
  46. data/.rubocop.yml +0 -36
  47. data/.travis.yml +0 -43
  48. data/Gemfile +0 -9
  49. data/README.rdoc +0 -225
  50. data/Rakefile +0 -78
  51. data/appveyor.yml +0 -18
  52. data/bench/pack.rb +0 -23
  53. data/bench/pack_log.rb +0 -33
  54. data/bench/pack_log_long.rb +0 -65
  55. data/bench/pack_symbols.rb +0 -28
  56. data/bench/run.sh +0 -14
  57. data/bench/run_long.sh +0 -35
  58. data/bench/run_symbols.sh +0 -26
  59. data/bench/unpack.rb +0 -21
  60. data/bench/unpack_log.rb +0 -34
  61. data/bench/unpack_log_long.rb +0 -67
  62. data/doclib/msgpack/buffer.rb +0 -193
  63. data/doclib/msgpack/core_ext.rb +0 -101
  64. data/doclib/msgpack/error.rb +0 -19
  65. data/doclib/msgpack/extension_value.rb +0 -9
  66. data/doclib/msgpack/factory.rb +0 -101
  67. data/doclib/msgpack/packer.rb +0 -208
  68. data/doclib/msgpack/time.rb +0 -22
  69. data/doclib/msgpack/timestamp.rb +0 -44
  70. data/doclib/msgpack/unpacker.rb +0 -183
  71. data/doclib/msgpack.rb +0 -87
  72. data/msgpack.org.md +0 -46
  73. data/spec/cases.json +0 -1
  74. data/spec/cases.msg +0 -0
  75. data/spec/cases_compact.msg +0 -0
  76. data/spec/cases_spec.rb +0 -39
  77. data/spec/cruby/buffer_io_spec.rb +0 -255
  78. data/spec/cruby/buffer_packer.rb +0 -29
  79. data/spec/cruby/buffer_spec.rb +0 -575
  80. data/spec/cruby/buffer_unpacker.rb +0 -19
  81. data/spec/cruby/unpacker_spec.rb +0 -70
  82. data/spec/ext_value_spec.rb +0 -99
  83. data/spec/exttypes.rb +0 -51
  84. data/spec/factory_spec.rb +0 -367
  85. data/spec/format_spec.rb +0 -301
  86. data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
  87. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
  88. data/spec/jruby/unpacker_spec.rb +0 -186
  89. data/spec/msgpack_spec.rb +0 -214
  90. data/spec/pack_spec.rb +0 -61
  91. data/spec/packer_spec.rb +0 -557
  92. data/spec/random_compat.rb +0 -24
  93. data/spec/spec_helper.rb +0 -38
  94. data/spec/timestamp_spec.rb +0 -121
  95. data/spec/unpack_spec.rb +0 -57
  96. data/spec/unpacker_spec.rb +0 -716
@@ -1,67 +0,0 @@
1
- # viiite report --regroup bench,threads bench/pack_log_long.rb
2
-
3
- require 'viiite'
4
- require 'msgpack'
5
-
6
- data_plain = MessagePack.pack({
7
- 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"'
8
- })
9
- data_structure = MessagePack.pack({
10
- 'remote_host' => '127.0.0.1',
11
- 'remote_user' => '-',
12
- 'date' => '10/Oct/2000:13:55:36 -0700',
13
- 'request' => 'GET /apache_pb.gif HTTP/1.0',
14
- 'method' => 'GET',
15
- 'path' => '/apache_pb.gif',
16
- 'protocol' => 'HTTP/1.0',
17
- 'status' => 200,
18
- 'bytes' => 2326,
19
- 'referer' => 'http://www.example.com/start.html',
20
- 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
21
- })
22
-
23
- seconds = 3600 # 1 hour
24
-
25
- Viiite.bench do |b|
26
- b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
27
- b.report(:plain) do
28
- ths = []
29
- end_at = Time.now + seconds
30
- threads.times do
31
- t = Thread.new do
32
- packs = 0
33
- while Time.now < end_at
34
- 10000.times do
35
- MessagePack.unpack(data_plain)
36
- end
37
- packs += 10000
38
- end
39
- packs
40
- end
41
- ths.push t
42
- end
43
- sum = ths.reduce(0){|r,t| r + t.value }
44
- puts "MessagePack.unpack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
45
- end
46
-
47
- b.report(:structure) do
48
- ths = []
49
- end_at = Time.now + seconds
50
- threads.times do
51
- t = Thread.new do
52
- packs = 0
53
- while Time.now < end_at
54
- 10000.times do
55
- MessagePack.unpack(data_structure)
56
- end
57
- packs += 10000
58
- end
59
- packs
60
- end
61
- ths.push t
62
- end
63
- sum = ths.reduce(0){|r,t| r + t.value }
64
- puts "MessagePack.unpack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
65
- end
66
- end
67
- end
@@ -1,193 +0,0 @@
1
- module MessagePack
2
-
3
- class Buffer
4
- #
5
- # Creates a MessagePack::Buffer instance.
6
- #
7
- # @overload initialize(options={})
8
- # @param options [Hash]
9
- #
10
- # @overload initialize(io, options={})
11
- # @param io [IO]
12
- # @param options [Hash]
13
- # This buffer writes written data into the IO when it is filled.
14
- # This buffer reads data from the IO when it is empty.
15
- #
16
- # _io_ must respond to readpartial(length, [,string]) or read(string) method and
17
- # write(string) or append(string) method.
18
- #
19
- # Supported options:
20
- #
21
- # * *:io_buffer_size* buffer size to read data from the internal IO. (default: 32768)
22
- # * *:read_reference_threshold* the threshold size to enable zero-copy deserialize optimization. Read strings longer than this threshold will refer the original string instead of copying it. (default: 256) (supported in MRI only)
23
- # * *:write_reference_threshold* the threshold size to enable zero-copy serialize optimization. The buffer refers written strings longer than this threshold instead of copying it. (default: 524288) (supported in MRI only)
24
- #
25
- def initialize(*args)
26
- end
27
-
28
- #
29
- # Makes the buffer empty
30
- #
31
- # @return nil
32
- #
33
- def clear
34
- end
35
-
36
- #
37
- # Returns byte size of the buffer.
38
- #
39
- # @return nil
40
- #
41
- def size
42
- end
43
-
44
- #
45
- # Returns _true_ if the buffer is empty.
46
- # This method is slightly faster than _size_.
47
- #
48
- # @return [Boolean]
49
- #
50
- def empty?
51
- end
52
-
53
- #
54
- # Appends the given data to the buffer.
55
- #
56
- # @param data [String]
57
- # @return [Integer] byte size written
58
- #
59
- def write(data)
60
- end
61
-
62
- #
63
- # Appends the given data to the buffer.
64
- #
65
- # @param data [String]
66
- # @return [Buffer] self
67
- #
68
- def <<(data)
69
- end
70
-
71
- #
72
- # Consumes _n_ bytes from the head of the buffer and returns consumed data.
73
- # If the size of the buffer is less than _n_, it reads all of data in the buffer.
74
- #
75
- # If _n_ is 0, it does nothing and returns an empty string.
76
- # If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
77
- #
78
- # @overload read
79
- #
80
- # @overload read(n)
81
- # @param n [Integer] bytes to read
82
- #
83
- # @overload read(n, buffer)
84
- # @param n [Integer] bytes to read
85
- # @param buffer [String] buffer to read into
86
- #
87
- # @return [String]
88
- #
89
- def read(n)
90
- end
91
-
92
- #
93
- # Consumes _n_ bytes from the head of the buffer and returns consumed data.
94
- # If the size of the buffer is less than _n_, it does nothing and raises EOFError.
95
- #
96
- # If _n_ is 0, it does nothing and returns an empty string.
97
- # If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
98
- #
99
- # @overload read_all
100
- #
101
- # @overload read_all(n)
102
- # @param n [Integer] bytes to read
103
- #
104
- # @overload read_all(n, buffer)
105
- # @param n [Integer] bytes to read
106
- # @param buffer [String] buffer to read into
107
- #
108
- # @return [String]
109
- #
110
- def read_all(n, buffer=nil)
111
- end
112
-
113
- #
114
- # Consumes _n_ bytes from the head of the buffer.
115
- # If the size of the buffer is less than _n_, it skips all of data in the buffer and returns integer less than _n_.
116
- #
117
- # If _n_ is 0, it does nothing and returns _0_.
118
- #
119
- # @param n [Integer] byte size to skip
120
- # @return [Integer] byte size actually skipped
121
- #
122
- def skip(n)
123
- end
124
-
125
- #
126
- # Consumes _n_ bytes from the head of the buffer.
127
- # If the size of the buffer is less than _n_, it does nothing and raises EOFError.
128
- # If _n_ is 0, it does nothing.
129
- #
130
- # @param n [Integer] byte size to skip
131
- # @return [Buffer] self
132
- #
133
- def skip_all(n)
134
- end
135
-
136
- #
137
- # Returns all data in the buffer as a string.
138
- # Destructive update to the returned string does NOT effect the buffer.
139
- #
140
- # @return [String]
141
- #
142
- def to_str
143
- end
144
-
145
- #
146
- # Returns content of the buffer as an array of strings.
147
- #
148
- # This method is sometimes faster than to_s because the internal
149
- # structure of the buffer is a queue of buffer chunks.
150
- #
151
- # @return [Array] array of strings
152
- #
153
- def to_a
154
- end
155
-
156
- #
157
- # Internal io
158
- #
159
- # @return IO
160
- #
161
- attr_reader :io
162
-
163
- #
164
- # Flushes data in the internal buffer to the internal IO.
165
- # If internal IO is not set, it does nothing.
166
- #
167
- # @return [Buffer] self
168
- #
169
- def flush
170
- end
171
-
172
- #
173
- # Closes internal IO if its set.
174
- # If internal IO is not set, it does nothing
175
- #
176
- # @return nil
177
- #
178
- def close
179
- end
180
-
181
- #
182
- # Writes all of data in the internal buffer into the given IO.
183
- # This method consumes and removes data from the internal buffer.
184
- # _io_ must respond to write(data) method.
185
- #
186
- # @param io [IO]
187
- # @return [Integer] byte size of written data
188
- #
189
- def write_to(io)
190
- end
191
- end
192
-
193
- end
@@ -1,101 +0,0 @@
1
-
2
- class NilClass
3
- #
4
- # Same as MessagePack.to_msgpack(self[, packer]).
5
- #
6
- # @return [String] serialized data
7
- #
8
- def to_msgpack(packer=nil)
9
- end
10
- end
11
-
12
- class TrueClass
13
- #
14
- # Same as MessagePack.to_msgpack(self[, packer]).
15
- #
16
- # @return [String] serialized data
17
- #
18
- def to_msgpack(packer=nil)
19
- end
20
- end
21
-
22
- class FalseClass
23
- #
24
- # Same as MessagePack.to_msgpack(self[, packer]).
25
- #
26
- # @return [String] serialized data
27
- #
28
- def to_msgpack(packer=nil)
29
- end
30
- end
31
-
32
- class Fixnum < Integer
33
- #
34
- # Same as MessagePack.to_msgpack(self[, packer]).
35
- #
36
- # @return [String] serialized data
37
- #
38
- def to_msgpack(packer=nil)
39
- end
40
- end
41
-
42
- class Bignum < Integer
43
- #
44
- # Same as MessagePack.to_msgpack(self[, packer]).
45
- #
46
- # @return [String] serialized data
47
- #
48
- def to_msgpack(packer=nil)
49
- end
50
- end
51
-
52
- class Float < Numeric
53
- #
54
- # Same as MessagePack.to_msgpack(self[, packer]).
55
- #
56
- # @return [String] serialized data
57
- #
58
- def to_msgpack(packer=nil)
59
- end
60
- end
61
-
62
- class String
63
- #
64
- # Same as MessagePack.to_msgpack(self[, packer]).
65
- #
66
- # @return [String] serialized data
67
- #
68
- def to_msgpack(packer=nil)
69
- end
70
- end
71
-
72
- class Array
73
- #
74
- # Same as MessagePack.to_msgpack(self[, packer]).
75
- #
76
- # @return [String] serialized data
77
- #
78
- def to_msgpack(packer=nil)
79
- end
80
- end
81
-
82
- class Hash
83
- #
84
- # Same as MessagePack.to_msgpack(self[, packer]).
85
- #
86
- # @return [String] serialized data
87
- #
88
- def to_msgpack(packer=nil)
89
- end
90
- end
91
-
92
- class Symbol
93
- #
94
- # Same as MessagePack.to_msgpack(self[, packer]).
95
- #
96
- # @return [String] serialized data
97
- #
98
- def to_msgpack(packer=nil)
99
- end
100
- end
101
-
@@ -1,19 +0,0 @@
1
- module MessagePack
2
-
3
- class UnpackError < StandardError
4
- end
5
-
6
- class MalformedFormatError < UnpackError
7
- end
8
-
9
- class StackError < UnpackError
10
- end
11
-
12
- class UnexpectedTypeError < UnpackError
13
- include TypeError
14
- end
15
-
16
- class UnknownExtTypeError < UnpackError
17
- include TypeError
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- module MessagePack
2
-
3
- #
4
- # MessagePack::ExtensionValue is a struct to represent unknown ext type object.
5
- # Its contents are accessed by type and payload (messagepack bytes representation) methods.
6
- # And it is extended to add to_msgpack object.
7
- #
8
- ExtensionValue = Struct.new(:type, :payload)
9
- end
@@ -1,101 +0,0 @@
1
- module MessagePack
2
- #
3
- # MessagePack::Factory is a class to generate Packer and Unpacker which has
4
- # same set of ext types.
5
- #
6
- class Factory
7
- #
8
- # Creates a MessagePack::Factory instance
9
- #
10
- def initialize
11
- end
12
-
13
- #
14
- # Creates a MessagePack::Packer instance, which has ext types already registered.
15
- # Options are passed to MessagePack::Packer#initialized.
16
- #
17
- # See also Packer#initialize for options.
18
- #
19
- def packer(*args)
20
- end
21
-
22
- #
23
- # Serialize the passed value
24
- #
25
- # If it could not serialize the object, it raises
26
- # NoMethodError: undefined method `to_msgpack' for #<the_object>.
27
- #
28
- # @param obj [Object] object to serialize
29
- # @param options [Hash]
30
- # @return [String] serialized object
31
- #
32
- # See Packer#initialize for supported options.
33
- #
34
- def dump(obj, options={})
35
- end
36
- alias pack dump
37
-
38
- #
39
- # Creates a MessagePack::Unpacker instance, which has ext types already registered.
40
- # Options are passed to MessagePack::Unpacker#initialized.
41
- #
42
- # See also Unpacker#initialize for options.
43
- #
44
- def unpacker(*args)
45
- end
46
-
47
- #
48
- # Deserializes an object from the string or io and returns it.
49
- #
50
- # If there're not enough data to deserialize one object, this method raises EOFError.
51
- # If data format is invalid, this method raises MessagePack::MalformedFormatError.
52
- # If the object nests too deeply, this method raises MessagePack::StackError.
53
- #
54
- # @param data [String]
55
- # @param options [Hash]
56
- # @return [Object] deserialized object
57
- #
58
- # See Unpacker#initialize for supported options.
59
- #
60
- def load(data, options={})
61
- end
62
- alias unpack load
63
-
64
- #
65
- # Register a type and Class to be registered for packer and/or unpacker.
66
- # If options are not speicified, factory will use :to_msgpack_ext for packer, and
67
- # :from_msgpack_ext for unpacker.
68
- #
69
- # @param type [Fixnum] type id of registered Class (0-127)
70
- # @param klass [Class] Class to be associated with type id
71
- # @param options [Hash] specify method name or Proc which are used by packer/unpacker
72
- # @return nil
73
- #
74
- # Supported options:
75
- #
76
- # * *:packer* specify symbol or proc object for packer
77
- # * *:unpacker* specify symbol or proc object for unpacker
78
- #
79
- def register_type(type, klass, options={})
80
- end
81
-
82
- #
83
- # Returns a list of registered types, ordered by type id.
84
- #
85
- # @param selector [Symbol] specify to list types registered for :packer, :unpacker or :both (default)
86
- # @return Array
87
- #
88
- def registered_types(selector=:both)
89
- end
90
-
91
- #
92
- # Returns true/false which indicate specified class or type id is registered or not.
93
- #
94
- # @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
95
- # @param selector [Symbol] specify to check for :packer, :unpacker or :both (default)
96
- # @return true or false
97
- #
98
- def type_registered?(klass_or_type, selector=:both)
99
- end
100
- end
101
- end
@@ -1,208 +0,0 @@
1
- module MessagePack
2
-
3
- #
4
- # MessagePack::Packer is a class to serialize objects.
5
- #
6
- class Packer
7
- #
8
- # Creates a MessagePack::Packer instance.
9
- # See Buffer#initialize for supported options.
10
- #
11
- # @overload initialize(options={})
12
- # @param options [Hash]
13
- #
14
- # @overload initialize(io, options={})
15
- # @param io [IO]
16
- # @param options [Hash]
17
- # This packer writes serialzied objects into the IO when the internal buffer is filled.
18
- # _io_ must respond to write(string) or append(string) method.
19
- #
20
- # Supported options:
21
- #
22
- # * *:compatibility_mode* serialize in older versions way, without str8 and bin types
23
- #
24
- # See also Buffer#initialize for other options.
25
- #
26
- def initialize(*args)
27
- end
28
-
29
- #
30
- # Register a new ext type to serialize it. This method should be called with one of
31
- # method name or block, which returns bytes(ASCII-8BIT String) representation of
32
- # object to be serialized.
33
- #
34
- # @overload register_type(type, klass, &block)
35
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
36
- # @param klass [Class] Class to be serialized with speicifed type id
37
- # @yieldparam object [Object] object to be serialized
38
- #
39
- # @overload register_type(type, klass, method_name)
40
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
41
- # @param klass [Class] Class to be serialized with speicifed type id
42
- # @param method_name [Symbol] method which returns bytes of serialized representation
43
- #
44
- # @return nil
45
- #
46
- def register_type(type, klass, method_name, &block)
47
- end
48
-
49
- #
50
- # Returns a list of registered types, ordered by type id.
51
- # Each element is a Hash object includes keys :type, :class and :packer.
52
- #
53
- # @return Array
54
- #
55
- def registered_types
56
- end
57
-
58
- #
59
- # Returns true/false which indicate specified class or type id is registered or not.
60
- #
61
- # @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
62
- # @return true or false
63
- #
64
- def type_registered?(klass_or_type)
65
- end
66
-
67
- #
68
- # Internal buffer
69
- #
70
- # @return MessagePack::Buffer
71
- #
72
- attr_reader :buffer
73
-
74
- #
75
- # Serializes an object into internal buffer, and flushes to io if necessary.
76
- #
77
- # If it could not serialize the object, it raises
78
- # NoMethodError: undefined method `to_msgpack' for #<the_object>.
79
- #
80
- # @param obj [Object] object to serialize
81
- # @return [Packer] self
82
- #
83
- def write(obj)
84
- end
85
-
86
- alias pack write
87
-
88
- #
89
- # Serializes a nil object. Same as write(nil).
90
- #
91
- def write_nil
92
- end
93
-
94
- #
95
- # Serializes a string object as binary data. Same as write("string".encode(Encoding::BINARY)).
96
- #
97
- def write_bin(obj)
98
- end
99
-
100
- #
101
- # Write a header of an array whose size is _n_.
102
- # For example, write_array_header(1).write(true) is same as write([ true ]).
103
- #
104
- # @return [Packer] self
105
- #
106
- def write_array_header(n)
107
- end
108
-
109
- #
110
- # Write a header of an map whose size is _n_.
111
- # For example, write_map_header(1).write('key').write(true) is same as write('key'=>true).
112
- #
113
- # @return [Packer] self
114
- #
115
- def write_map_header(n)
116
- end
117
-
118
- #
119
- # Write a header of a binary string whose size is _n_. Useful if you want to append large binary data without loading it into memory at once.
120
- # For example,
121
- # MessagePack::Packer.new(io).write_bin_header(12).flush
122
- # io.write('chunk1')
123
- # io.write('chunk2')
124
- # is the same as
125
- # write('chunk1chunk2'.encode(Encoding::BINARY)).
126
- #
127
- # @return [Packer] self
128
- #
129
- def write_bin_header(n)
130
- end
131
-
132
- #
133
- # Serializes _value_ as 32-bit single precision float into internal buffer.
134
- # _value_ will be approximated with the nearest possible single precision float, thus
135
- # being potentially lossy. However, the serialized string will only take up 5 bytes
136
- # instead of 9 bytes compared to directly serializing a 64-bit double precision Ruby Float.
137
- #
138
- # @param value [Numeric]
139
- # @return [Packer] self
140
- #
141
- def write_float32(value)
142
- end
143
-
144
- #
145
- # Flushes data in the internal buffer to the internal IO. Same as _buffer.flush.
146
- # If internal IO is not set, it does nothing.
147
- #
148
- # @return [Packer] self
149
- #
150
- def flush
151
- end
152
-
153
- #
154
- # Makes the internal buffer empty. Same as _buffer.clear_.
155
- #
156
- # @return nil
157
- #
158
- def clear
159
- end
160
-
161
- #
162
- # Returns size of the internal buffer. Same as buffer.size.
163
- #
164
- # @return [Integer]
165
- #
166
- def size
167
- end
168
-
169
- #
170
- # Returns _true_ if the internal buffer is empty. Same as buffer.empty?.
171
- # This method is slightly faster than _size_.
172
- #
173
- # @return [Boolean]
174
- #
175
- def empty?
176
- end
177
-
178
- #
179
- # Returns all data in the buffer as a string. Same as buffer.to_str.
180
- #
181
- # @return [String]
182
- #
183
- def to_str
184
- end
185
-
186
- alias to_s to_str
187
-
188
- #
189
- # Returns content of the internal buffer as an array of strings. Same as buffer.to_a.
190
- # This method is faster than _to_str_.
191
- #
192
- # @return [Array] array of strings
193
- #
194
- def to_a
195
- end
196
-
197
- #
198
- # Writes all of data in the internal buffer into the given IO. Same as buffer.write_to(io).
199
- # This method consumes and removes data from the internal buffer.
200
- # _io_ must respond to write(data) method.
201
- #
202
- # @param io [IO]
203
- # @return [Integer] byte size of written data
204
- #
205
- def write_to(io)
206
- end
207
- end
208
- end