Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/bert/encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def write_to(io)
@buf.each { |x| io.write x }
end

def to_s
@buf.join("")
end

def bytesize
@buf.map(&:bytesize).inject :+
end
Expand All @@ -74,11 +78,7 @@ def self.encode_to_buffer(data)
end

def self.encode(data)
buf = encode_to_buffer data
io = StringIO.new
io.set_encoding('binary') if io.respond_to?(:set_encoding)
buf.write_to io
io.string
encode_to_buffer(data).to_s
end

def self.encode_data(data, io)
Expand Down