Class: Gapic::Schema::Enum

Inherits:
Proto
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gapic/schema/wrappers.rb

Overview

Wrapper for a protobuf enum.

Instance Attribute Summary collapse

Attributes inherited from Proto

#address, #descriptor, #docs, #parent

Instance Method Summary collapse

Methods inherited from Proto

#containing_api, #containing_file, #docs_leading_comments, #leading_comments, #leading_detached_comments, #option_extension_names, #option_named, #path, #span, #trailing_comments

Constructor Details

#initialize(descriptor, address, docs, values) ⇒ Enum

Initializes a message object.

Parameters:

  • descriptor (Google::Protobuf::DescriptorProto)

    the protobuf representation of this service.

  • address (Enumerable<String>)

    The address of the proto. See

    address for more info.

  • docs (Google::Protobuf::SourceCodeInfo::Location)

    The docs of the proto. See #docs for more info.

  • values (Enumerable<EnumValue>)

    The EnumValues of this enum.



606
607
608
609
610
# File 'lib/gapic/schema/wrappers.rb', line 606

def initialize descriptor, address, docs, values
  super descriptor, address, docs
  @values = values || []
  @values.each { |v| v.parent = self }
end

Instance Attribute Details

#valuesObject (readonly)

@ return [EnumValue] the EnumValues contained in this file.



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/gapic/schema/wrappers.rb', line 593

class Enum < Proto
  extend Forwardable

  attr_reader :values

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param values [Enumerable<EnumValue>] The EnumValues of this enum.
  def initialize descriptor, address, docs, values
    super descriptor, address, docs
    @values = values || []
    @values.each { |v| v.parent = self }
  end

  # @return [Boolean] True if this enum is marked as deprecated, false
  #   otherwise.
  def is_deprecated?
    option_named "deprecated"
  end

  # @!method name
  #   @return [String] the unqualified name of the Enum.
  # @!method options
  #   @return [Array<Google::Protobuf::EnumOptions>] the options of the
  #     enum.
  def_delegators(
    :descriptor,
    :name,
    :options
  )
end

Instance Method Details

#is_deprecated?Boolean

Returns True if this enum is marked as deprecated, false otherwise.

Returns:

  • (Boolean)

    True if this enum is marked as deprecated, false otherwise.



614
615
616
# File 'lib/gapic/schema/wrappers.rb', line 614

def is_deprecated?
  option_named "deprecated"
end

#nameString

Returns the unqualified name of the Enum.

Returns:

  • (String)

    the unqualified name of the Enum.



623
624
625
626
627
# File 'lib/gapic/schema/wrappers.rb', line 623

def_delegators(
  :descriptor,
  :name,
  :options
)

#optionsArray<Google::Protobuf::EnumOptions>

Returns the options of the enum.

Returns:

  • (Array<Google::Protobuf::EnumOptions>)

    the options of the enum.



623
624
625
626
627
# File 'lib/gapic/schema/wrappers.rb', line 623

def_delegators(
  :descriptor,
  :name,
  :options
)