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
Class Attribute Summary (collapse)
-
+ (Object) values
readonly
Returns the value of attribute values.
Class Method Summary (collapse)
- + (Object) descriptor
- + (Object) name_by_value(value) (also: get_name_by_tag)
- + (Boolean) valid_tag?(tag)
Methods included from Protoable
defined_filenames, defined_in, proto_contents, proto_filenames, retrieve_header
Class Attribute Details
+ (Object) values (readonly)
Returns the value of attribute values
11 12 13 |
# File 'lib/protobuf/message/enum.rb', line 11 def values @values end |
Class Method Details
+ (Object) descriptor
28 29 30 |
# File 'lib/protobuf/message/enum.rb', line 28 def descriptor @descriptor ||= Descriptor::EnumDescriptor.new(self) end |
+ (Object) name_by_value(value) Also known as: get_name_by_tag
13 14 15 16 17 18 19 20 |
# File 'lib/protobuf/message/enum.rb', line 13 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.to_i] = n; hash } @values_index[value] end end |
+ (Boolean) valid_tag?(tag)
24 25 26 |
# File 'lib/protobuf/message/enum.rb', line 24 def valid_tag?(tag) !! name_by_value(tag) end |