Class: Protobuf::Field::BaseFieldObjectDefinitions::BytesEncodeToStream
- Inherits:
-
Object
- Object
- Protobuf::Field::BaseFieldObjectDefinitions::BytesEncodeToStream
- Defined in:
- lib/protobuf/field/base_field_object_definitions.rb
Instance Method Summary collapse
- #call(value, stream) ⇒ Object
-
#initialize(selph) ⇒ BytesEncodeToStream
constructor
A new instance of BytesEncodeToStream.
Constructor Details
#initialize(selph) ⇒ BytesEncodeToStream
Returns a new instance of BytesEncodeToStream.
62 63 64 65 |
# File 'lib/protobuf/field/base_field_object_definitions.rb', line 62 def initialize(selph) @selph = selph @tag_encoded = selph.tag_encoded end |
Instance Method Details
#call(value, stream) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/protobuf/field/base_field_object_definitions.rb', line 67 def call(value, stream) value = value.encode if value.is_a?(::Protobuf::Message) byte_size = ::Protobuf::Field::VarintField.encode(value.bytesize) stream << @tag_encoded << byte_size << value end |