class Protobuf::Field::BaseFieldObjectDefinitions::RepeatedPackedSetMethod

Public Class Methods

new(selph) click to toggle source
# File lib/protobuf/field/base_field_object_definitions.rb, line 154
def initialize(selph)
  @selph = selph
  @name = selph.name
  @wire_type = selph.wire_type
end

Public Instance Methods

call(message_instance, bytes) click to toggle source
# File lib/protobuf/field/base_field_object_definitions.rb, line 160
def call(message_instance, bytes)
  array = message_instance[@name]
  stream = ::StringIO.new(bytes)

  if @wire_type == ::Protobuf::WireType::VARINT
    array << @selph.decode(Varint.decode(stream)) until stream.eof?
  elsif @wire_type == ::Protobuf::WireType::FIXED64
    array << @selph.decode(stream.read(8)) until stream.eof?
  elsif @wire_type == ::Protobuf::WireType::FIXED32
    array << @selph.decode(stream.read(4)) until stream.eof?
  end
end