Module: Protobuf::Descriptor
- Defined in:
- lib/protobuf/descriptor/descriptor.rb,
lib/protobuf/descriptor/enum_descriptor.rb,
lib/protobuf/descriptor/file_descriptor.rb,
lib/protobuf/descriptor/field_descriptor.rb,
lib/protobuf/descriptor/descriptor_builder.rb
Defined Under Namespace
Classes: Descriptor, DescriptorBuilder, EnumDescriptor, FieldDescriptor, FileDescriptor
Class Method Summary collapse
- .id2label(label_id) ⇒ Object
- .id2type(type_id) ⇒ Object
- .label2id(label) ⇒ Object
- .type2id(type) ⇒ Object
Class Method Details
.id2label(label_id) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/protobuf/descriptor/descriptor_builder.rb', line 93 def self.id2label(label_id) require 'protobuf/descriptor/descriptor_proto' case label_id when Google::Protobuf::FieldDescriptorProto::Label::LABEL_REQUIRED :required when Google::Protobuf::FieldDescriptorProto::Label::LABEL_OPTIONAL :optional when Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED :repeated else raise ArgumentError, "Invalid label: #{proto.label}" end end |
.id2type(type_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/protobuf/descriptor/descriptor_builder.rb', line 5 def self.id2type(type_id) require 'protobuf/descriptor/descriptor_proto' case type_id when Google::Protobuf::FieldDescriptorProto::Type::TYPE_DOUBLE :double when Google::Protobuf::FieldDescriptorProto::Type::TYPE_FLOAT :float when Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT64 :int64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT64 :unit64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT32 :int64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED64 :fixed64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED32 :fixed32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_BOOL :bool when Google::Protobuf::FieldDescriptorProto::Type::TYPE_STRING :string when Google::Protobuf::FieldDescriptorProto::Type::TYPE_GROUP :group when Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE :message when Google::Protobuf::FieldDescriptorProto::Type::TYPE_BYTES :bytes when Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT32 :uint32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_ENUM :enum when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED32 :sfixed32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED64 :sfixed64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT32 :sint32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT64 :sint64 else raise ArgumentError, "Invalid type: #{proto.type}" end end |
.label2id(label) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/protobuf/descriptor/descriptor_builder.rb', line 107 def self.label2id(label) require 'protobuf/descriptor/descriptor_proto' case label when :required Google::Protobuf::FieldDescriptorProto::Label::LABEL_REQUIRED when :optional Google::Protobuf::FieldDescriptorProto::Label::LABEL_OPTIONAL when :repeated Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED else raise ArgumentError, "Invalid label: #{label}" end end |
.type2id(type) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/protobuf/descriptor/descriptor_builder.rb', line 49 def self.type2id(type) require 'protobuf/descriptor/descriptor_proto' case type when :double Google::Protobuf::FieldDescriptorProto::Type::TYPE_DOUBLE when :float Google::Protobuf::FieldDescriptorProto::Type::TYPE_FLOAT when :int64 Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT64 when :unit64 Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT64 when :int64 Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT32 when :fixed64 Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED64 when :fixed32 Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_BOOL :bool when :string Google::Protobuf::FieldDescriptorProto::Type::TYPE_STRING when :group Google::Protobuf::FieldDescriptorProto::Type::TYPE_GROUP when :message Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE when :bytes Google::Protobuf::FieldDescriptorProto::Type::TYPE_BYTES when :uint32 Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT32 when :enum Google::Protobuf::FieldDescriptorProto::Type::TYPE_ENUM when :sfixed32 Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED32 when :sfixed64 Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED64 when :sint32 Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT32 when :sint64 Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT64 else Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE end end |