Sha256: 335440960a3bfd4fb345ed8c050eb36ed8021897a0f42a790e21e9a7ca3bd4d4

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

class ProtobufDescriptor
  # Describes an enum type.
  #
  # See {+EnumDescriptorProto+}[https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/descriptor.proto#171]
  class EnumDescriptor
    include ProtobufDescriptor::HasParent
    include ProtobufDescriptor::NamedChild
    include ProtobufDescriptor::HasChildren

    # The containing {ProtobufDescriptor::FileDescriptor} or
    # {ProtobufDescriptor::MessageDescriptor} that defines this enum.
    attr_reader :parent

    # The +EnumDescriptorProto+ this +EnumDescriptor+ is wrapping.
    attr_reader :enum_descriptor_proto

    # List of the enum values for this `EnumDescriptor` as a `NamedCollection`
    # of {ProtobufDescriptor::EnumValueDescriptor}
    attr_reader :value
    alias_method :values, :value

    register_children(:value, 2)

    def initialize(parent, enum_descriptor_proto)
      @parent = parent
      @enum_descriptor_proto = enum_descriptor_proto

      @value = ProtobufDescriptor::NamedCollection.new(
          enum_descriptor_proto.value.map { |m|
            ProtobufDescriptor::EnumValueDescriptor.new(self, m)
          })
    end

    # The name of the enum
    def name; enum_descriptor_proto.name; end

    # The +EnumOptions+ defined for this enum
    def options; enum_descriptor_proto.options; end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
protobuf_descriptor-1.1.2 lib/protobuf_descriptor/enum_descriptor.rb
protobuf_descriptor-1.1.1 lib/protobuf_descriptor/enum_descriptor.rb
protobuf_descriptor-1.1.0 lib/protobuf_descriptor/enum_descriptor.rb