Class: Protopuffs::Bytes

Inherits:
LengthDelimited show all
Defined in:
lib/protopuffs/message/field.rb

Instance Attribute Summary

Attributes inherited from MessageField

#default, #identifier, #tag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LengthDelimited

shift, wire_type

Methods inherited from MessageField

factory, #key, #optional?, #repeated?, shift_tag, #to_wire_format_with_value

Constructor Details

#initialize(modifier, identifier, tag, default = nil) ⇒ Bytes

Returns a new instance of Bytes.



198
199
200
# File 'lib/protopuffs/message/field.rb', line 198

def initialize(modifier, identifier, tag, default = nil)
  super
end

Class Method Details

.encode(value) ⇒ Object



201
202
203
# File 'lib/protopuffs/message/field.rb', line 201

def self.encode(value)
  VarInt.encode(value.size) + value
end

Instance Method Details

#decode(bytes) ⇒ Object



204
205
206
# File 'lib/protopuffs/message/field.rb', line 204

def decode(bytes)
  bytes.respond_to?(:force_encoding) ? bytes.force_encoding("BINARY") : bytes
end