Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 803 Bytes

README.md

File metadata and controls

28 lines (21 loc) · 803 Bytes

PB IO

Test License

Protobuf IO is a Ruby equivalent of https://godoc.org/github.com/gogo/protobuf/io.

Installation

Add gem 'pbio' to your Gemfile.

Usage

File.open("file.txt", "w") do |f|
  pbio = PBIO::Delimited.new(f)
  pbio.write MyProtoMsg.new(title: "Foo")
  pbio.write MyProtoMsg.new(title: "Bar")
end

File.open("file.txt", "r") do |f|
  pbio = PBIO::Delimited.new(f)
  pbio.read MyProtoMsg # => #<MyProtoMsg: title: "Foo">
  pbio.read MyProtoMsg # => #<MyProtoMsg: title: "Bar">
  pbio.read MyProtoMsg # => nil
  f.eof?               # => true
end