Class: ProtoPlugin::EnumValueDescriptor

Inherits:
SimpleDelegator
  • Object
show all
Includes:
Commentable
Defined in:
lib/proto_plugin/enum_value_descriptor.rb

Overview

A wrapper class around Google::Protobuf::EnumValueDescriptorProto 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

Instance Method Summary collapse

Methods included from Commentable

#comments, #leading_comments, #source_location, #trailing_comments

Constructor Details

#initialize(descriptor, enum) ⇒ EnumValueDescriptor

Returns a new instance of EnumValueDescriptor.

Parameters:

  • descriptor (Google::Protobuf::EnumValueDescriptorProto)
  • enum (EnumDescriptor)

    The enum this value was defined within.



26
27
28
29
30
# File 'lib/proto_plugin/enum_value_descriptor.rb', line 26

def initialize(descriptor, enum)
  super(descriptor)
  @descriptor = descriptor
  @enum = enum
end

Instance Attribute Details

#descriptorGoogle::Protobuf::EnumValueDescriptorProto (readonly)

Returns:

  • (Google::Protobuf::EnumValueDescriptorProto)


17
18
19
# File 'lib/proto_plugin/enum_value_descriptor.rb', line 17

def descriptor
  @descriptor
end

#enumEnumDescriptor (readonly)

The enum descriptor this value was defined within.

Returns:



22
23
24
# File 'lib/proto_plugin/enum_value_descriptor.rb', line 22

def enum
  @enum
end

Instance Method Details

#fileFileDescriptor

The file descriptor this enum value belongs to.

Returns:



35
36
37
# File 'lib/proto_plugin/enum_value_descriptor.rb', line 35

def file
  enum.file
end

#full_nameString

The full name of the enum value, including parent namespace.

Examples:

"My::Ruby::Package::EnumName::VALUE_NAME"

Returns:

  • (String)


45
46
47
# File 'lib/proto_plugin/enum_value_descriptor.rb', line 45

def full_name
  @full_name ||= "#{enum.full_name}::#{name}"
end