Class: ProtoPlugin::OneofDescriptor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProtoPlugin::OneofDescriptor
- Includes:
- Commentable
- Defined in:
- lib/proto_plugin/oneof_descriptor.rb
Overview
A wrapper class around Google::Protobuf::OneofDescriptorProto which provides helpers and more idiomatic Ruby access patterns.
Any method not defined directly is delegated to the descriptor the wrapper was initialized with.
Instance Attribute Summary collapse
- #descriptor ⇒ Google::Protobuf::OneofDescriptorProto readonly
-
#index ⇒ Integer
readonly
The index of this oneof within its message’s
oneof_decllist. -
#message ⇒ MessageDescriptor
readonly
The message descriptor this oneof was defined within.
Instance Method Summary collapse
-
#fields ⇒ Array<FieldDescriptor>
The fields that are members of this oneof.
-
#file ⇒ FileDescriptor
The file descriptor this oneof belongs to.
-
#initialize(descriptor, message, index) ⇒ OneofDescriptor
constructor
A new instance of OneofDescriptor.
Methods included from Commentable
#comments, #leading_comments, #source_location, #trailing_comments
Constructor Details
#initialize(descriptor, message, index) ⇒ OneofDescriptor
Returns a new instance of OneofDescriptor.
32 33 34 35 36 37 |
# File 'lib/proto_plugin/oneof_descriptor.rb', line 32 def initialize(descriptor, , index) super(descriptor) @descriptor = descriptor @message = @index = index end |
Instance Attribute Details
#descriptor ⇒ Google::Protobuf::OneofDescriptorProto (readonly)
17 18 19 |
# File 'lib/proto_plugin/oneof_descriptor.rb', line 17 def descriptor @descriptor end |
#index ⇒ Integer (readonly)
The index of this oneof within its message’s oneof_decl list.
27 28 29 |
# File 'lib/proto_plugin/oneof_descriptor.rb', line 27 def index @index end |
#message ⇒ MessageDescriptor (readonly)
The message descriptor this oneof was defined within.
22 23 24 |
# File 'lib/proto_plugin/oneof_descriptor.rb', line 22 def @message end |
Instance Method Details
#fields ⇒ Array<FieldDescriptor>
The fields that are members of this oneof.
49 50 51 52 53 |
# File 'lib/proto_plugin/oneof_descriptor.rb', line 49 def fields @fields ||= .fields.select do |field| field.oneof? && field.oneof_index == index end end |
#file ⇒ FileDescriptor
The file descriptor this oneof belongs to.
42 43 44 |
# File 'lib/proto_plugin/oneof_descriptor.rb', line 42 def file .file end |