Class: Protobuf::Enum
- Inherits:
-
Object
- Object
- Protobuf::Enum
- Extended by:
- Protoable
- Defined in:
- lib/protobuf/message/enum.rb
Direct Known Subclasses
Google::Protobuf::FieldDescriptorProto::Label, Google::Protobuf::FieldDescriptorProto::Type, Google::Protobuf::FieldOptions::CType, Google::Protobuf::FileOptions::OptimizeMode, Socketrpc::ErrorReason
Class Attribute Summary collapse
-
.values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
- .descriptor ⇒ Object
- .name_by_value(value) ⇒ Object (also: get_name_by_tag)
- .valid_tag?(tag) ⇒ Boolean
Methods included from Protoable
defined_filenames, defined_in, proto_contents, proto_filenames, retrieve_header
Class Attribute Details
.values ⇒ Object (readonly)
Returns the value of attribute values.
10 11 12 |
# File 'lib/protobuf/message/enum.rb', line 10 def values @values end |
Class Method Details
.descriptor ⇒ Object
27 28 29 |
# File 'lib/protobuf/message/enum.rb', line 27 def descriptor @descriptor ||= Descriptor::EnumDescriptor.new(self) end |
.name_by_value(value) ⇒ Object Also known as: get_name_by_tag
12 13 14 15 16 17 18 19 |
# File 'lib/protobuf/message/enum.rb', line 12 def name_by_value(value) if not defined?(@values) constants.find {|c| const_get(c) == value} # for compatibility else @values_index ||= @values.inject({}) {|hash, (n, v)| hash[v.value] = n; hash } @values_index[value] end end |
.valid_tag?(tag) ⇒ Boolean
23 24 25 |
# File 'lib/protobuf/message/enum.rb', line 23 def valid_tag?(tag) !! name_by_value(tag) end |