Class: ProtoPlugin::EnumDescriptor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProtoPlugin::EnumDescriptor
- Includes:
- Commentable
- Defined in:
- lib/proto_plugin/enum_descriptor.rb
Overview
A wrapper class around Google::Protobuf::EnumDescriptorProto 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::EnumDescriptorProto readonly
-
#parent ⇒ FileDescriptor, MessageDescriptor
readonly
The file or message descriptor this enum was defined within.
Instance Method Summary collapse
-
#file ⇒ FileDescriptor
The file descriptor this enum belongs to.
-
#full_name ⇒ String
The full name of the enum, including parent namespace.
-
#initialize(descriptor, parent) ⇒ EnumDescriptor
constructor
A new instance of EnumDescriptor.
-
#values ⇒ Array<EnumValueDescriptor>
The values defined for this enum.
Methods included from Commentable
#comments, #leading_comments, #source_location, #trailing_comments
Constructor Details
#initialize(descriptor, parent) ⇒ EnumDescriptor
Returns a new instance of EnumDescriptor.
27 28 29 30 31 |
# File 'lib/proto_plugin/enum_descriptor.rb', line 27 def initialize(descriptor, parent) super(descriptor) @descriptor = descriptor @parent = parent end |
Instance Attribute Details
#descriptor ⇒ Google::Protobuf::EnumDescriptorProto (readonly)
16 17 18 |
# File 'lib/proto_plugin/enum_descriptor.rb', line 16 def descriptor @descriptor end |
#parent ⇒ FileDescriptor, MessageDescriptor (readonly)
The file or message descriptor this enum was defined within.
22 23 24 |
# File 'lib/proto_plugin/enum_descriptor.rb', line 22 def parent @parent end |
Instance Method Details
#file ⇒ FileDescriptor
The file descriptor this enum belongs to.
36 37 38 |
# File 'lib/proto_plugin/enum_descriptor.rb', line 36 def file parent.file end |
#full_name ⇒ String
The full name of the enum, including parent namespace.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/proto_plugin/enum_descriptor.rb', line 58 def full_name @full_name ||= begin prefix = case parent when MessageDescriptor parent.full_name when FileDescriptor parent.namespace end "#{prefix}::#{name}" end end |
#values ⇒ Array<EnumValueDescriptor>
The values defined for this enum.
46 47 48 49 50 |
# File 'lib/proto_plugin/enum_descriptor.rb', line 46 def values @values ||= @descriptor.value.map do |v| EnumValueDescriptor.new(v, self) end end |