Class: Protobuf::Enum

Inherits:
Object
  • Object
show all
Extended by:
Protoable
Defined in:
lib/protobuf/message/enum.rb

Class Method Summary collapse

Methods included from Protoable

defined_filenames, defined_in, proto_contents, proto_filenames, retrieve_header

Class Method Details

.descriptorObject



23
24
25
# File 'lib/protobuf/message/enum.rb', line 23

def descriptor
  @descriptor ||= Protobuf::Descriptor::EnumDescriptor.new(self)
end

.get_name_by_tag(tag) ⇒ Object



9
10
11
12
13
# File 'lib/protobuf/message/enum.rb', line 9

def get_name_by_tag(tag)
  constants.find do |name|
    const_get(name) == tag
  end
end

.name_by_value(value) ⇒ Object



19
20
21
# File 'lib/protobuf/message/enum.rb', line 19

def name_by_value(value)
  constants.find {|c| const_get(c) == value}
end

.valid_tag?(tag) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/protobuf/message/enum.rb', line 15

def valid_tag?(tag)
  not get_name_by_tag(tag).nil?
end