class Protobuf::Field::StringField
Constants
- ENCODING
Constants
Public Instance Methods
decode(bytes)
click to toggle source
Public Instance Methods
# File lib/protobuf/field/string_field.rb, line 17 def decode(bytes) bytes_to_decode = bytes.dup bytes_to_decode.force_encoding(::Protobuf::Field::StringField::ENCODING) bytes_to_decode end
encode(value)
click to toggle source
# File lib/protobuf/field/string_field.rb, line 23 def encode(value) value_to_encode = value.dup value_to_encode.encode!(::Protobuf::Field::StringField::ENCODING, :invalid => :replace, :undef => :replace, :replace => "") value_to_encode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING) "#{::Protobuf::Field::VarintField.encode(value_to_encode.size)}#{value_to_encode}" end