Sha256: 0944278c3d331d00d643ce1c15a6e3ecdb680b1852f0745bb5875d505e3d1771

Contents?: true

Size: 649 Bytes

Versions: 11

Compression:

Stored size: 649 Bytes

Contents

module Protobuf
  class Encoder
    def self.encode(message, stream)
      message.each_field_for_serialization do |field, value|
        if field.repeated?
          if field.packed?
            packed_value = value.map { |val| field.encode(val) }.join
            stream << "#{field.tag_encoded}#{::Protobuf::Field::VarintField.encode(packed_value.size)}#{packed_value}"
          else
            value.each do |val|
              stream << "#{field.tag_encoded}#{field.encode(val)}"
            end
          end
        else
          stream << "#{field.tag_encoded}#{field.encode(value)}"
        end
      end

      stream
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
protobuffy-4.0.1 lib/protobuf/encoder.rb
protobuffy-4.0.0 lib/protobuf/encoder.rb
protobuf-3.6.12 lib/protobuf/encoder.rb
protobuf-3.6.11 lib/protobuf/encoder.rb
protobuf-3.6.10 lib/protobuf/encoder.rb
protobuf-3.7.0.pre2 lib/protobuf/encoder.rb
protobuf-3.6.9 lib/protobuf/encoder.rb
protobuf-3.7.0.pre1 lib/protobuf/encoder.rb
protobuf-3.7.0.pre0 lib/protobuf/encoder.rb
protobuf-3.6.7 lib/protobuf/encoder.rb
protobuf-3.6.6 lib/protobuf/encoder.rb