lib/protocol_buffers/runtime/message.rb in ruby-protocol-buffers-0.8.4 vs lib/protocol_buffers/runtime/message.rb in ruby-protocol-buffers-0.8.5
- old
+ new
@@ -56,11 +56,11 @@
# with the same name as the field. How you can manipulate the member depends
# on its type.
#
# === Singular Fields
#
- # If you have a singular (optional or repeated) field +foo+ of any non-message
+ # If you have a singular (optional or required) field +foo+ of any non-message
# type, you can manipulate the field +foo+ as if it were a regular object
# attribute. For example, if +foo+'s type is <tt>int32</tt>, you can say:
#
# message.foo = 123
# puts message.foo
@@ -265,11 +265,11 @@
io
end
# Serialize this Message to a String and return it.
def serialize_to_string
- sio = StringIO.new
+ sio = ProtocolBuffers.bin_sio
serialize(sio)
return sio.string
end
alias_method :to_s, :serialize_to_string
@@ -283,11 +283,11 @@
# new_message.parse(io)
# merge_from(new_message)
def parse(io_or_string)
io = io_or_string
if io.is_a?(String)
- io = StringIO.new(io)
+ io = ProtocolBuffers.bin_sio(io)
end
Decoder.decode(io, self)
return self
end
@@ -394,10 +394,10 @@
def value_for_tag?(tag)
@set_fields[tag] || false
end
def inspect
- ret = StringIO.new
+ ret = ProtocolBuffers.bin_sio
ret << "#<#{self.class.name}"
fields.each do |tag, field|
ret << " #{field.name}=#{field.inspect_value(self.__send__(field.name))}"
end
ret << ">"