Class: Protobuf::Encoder
- Inherits:
-
Object
- Object
- Protobuf::Encoder
- Defined in:
- lib/protobuf/encoder.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(message, stream) ⇒ Encoder
constructor
A new instance of Encoder.
Constructor Details
#initialize(message, stream) ⇒ Encoder
Returns a new instance of Encoder.
10 11 12 13 14 15 16 17 |
# File 'lib/protobuf/encoder.rb', line 10 def initialize(, stream) unless .respond_to?(:each_field_for_serialization) raise ArgumentError, "Message instance must respond to :each_field_for_serialization" end @message = @stream = stream end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/protobuf/encoder.rb', line 8 def @message end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
8 9 10 |
# File 'lib/protobuf/encoder.rb', line 8 def stream @stream end |
Class Method Details
.encode(stream, message) ⇒ Object
4 5 6 |
# File 'lib/protobuf/encoder.rb', line 4 def self.encode(stream, ) new(stream, ).encode end |
Instance Method Details
#encode ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/protobuf/encoder.rb', line 19 def encode .each_field_for_serialization do |field, value| encode_field(field, value) end stream end |