Class: OdpsProtobuf::StringField
- Inherits:
-
Object
- Object
- OdpsProtobuf::StringField
- Defined in:
- lib/odps_protobuf/field/string_field.rb
Class Method Summary collapse
Class Method Details
.decode(value) ⇒ Object
13 14 15 16 17 |
# File 'lib/odps_protobuf/field/string_field.rb', line 13 def decode(value) bytes_to_decode = value.dup bytes_to_decode.force_encoding(::Protobuf::Field::StringField::ENCODING) bytes_to_decode end |
.encode(value) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/odps_protobuf/field/string_field.rb', line 5 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) string_bytes = ::Protobuf::Field::VarintField.encode(value_to_encode.size) string_bytes << value_to_encode end |