class ProtobufDescriptor::FieldDescriptor
Describes a field within a message.
Attributes
The FieldDescriptorProto
this FieldDescriptor
is wrapping.
The parent {ProtobufDescriptor::MessageDescriptor}
Public Class Methods
# File lib/protobuf_descriptor/field_descriptor.rb, line 13 def initialize(parent, field_descriptor_proto) @parent = parent @field_descriptor_proto = field_descriptor_proto end
Public Instance Methods
Default value for this field.
-
For numeric types, contains the original text representation of the value.
-
For booleans, “true” or “false”.
-
For strings, contains the default text contents (not escaped in any way).
-
For bytes, contains the C escaped value. All bytes >= 128 are escaped.
# File lib/protobuf_descriptor/field_descriptor.rb, line 31 def default_value field_descriptor_proto.default_value end
For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name.
# File lib/protobuf_descriptor/field_descriptor.rb, line 37 def extendee field_descriptor_proto.extendee end
Whether the field is optional/required/repeated.
# File lib/protobuf_descriptor/field_descriptor.rb, line 53 def label field_descriptor_proto.label end
The name of this field.
# File lib/protobuf_descriptor/field_descriptor.rb, line 63 def name field_descriptor_proto.name end
The tag number of this field.
# File lib/protobuf_descriptor/field_descriptor.rb, line 58 def number field_descriptor_proto.number end
The FieldOptions
for this field
# File lib/protobuf_descriptor/field_descriptor.rb, line 19 def options field_descriptor_proto.options end
Resolves the field’s type_name
, returning the {ProtobufDescriptor::MessageDescriptor} or {ProtobufDescriptor::EnumDescriptor} that this field will represent.
# File lib/protobuf_descriptor/field_descriptor.rb, line 76 def resolve_type protobuf_descriptor.resolve_type_name(self.type_name, self.parent) end
For message and enum types, this is the name of the type. If the name starts with a ‘.’, it is fully-qualified. Otherwise, C++-like scoping rules are used to find the type (i.e. first the nested types within this message are searched, then within the parent, on up to the root namespace).
Note: the protocol buffer compiler always emits the fully qualified name!
# File lib/protobuf_descriptor/field_descriptor.rb, line 48 def type_name field_descriptor_proto.type_name end