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 then :required when Google::Protobuf::FieldDescriptorProto::Label::LABEL_OPTIONAL then :optional when Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED then :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 then :double when Google::Protobuf::FieldDescriptorProto::Type::TYPE_FLOAT then :float when Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT64 then :int64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT64 then :unit64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT32 then :int64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED64 then :fixed64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED32 then :fixed32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_BOOL then :bool when Google::Protobuf::FieldDescriptorProto::Type::TYPE_STRING then :string when Google::Protobuf::FieldDescriptorProto::Type::TYPE_GROUP then :group when Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE then :message when Google::Protobuf::FieldDescriptorProto::Type::TYPE_BYTES then :bytes when Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT32 then :uint32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_ENUM then :enum when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED32 then :sfixed32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED64 then :sfixed64 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT32 then :sint32 when Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT64 then :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 then Google::Protobuf::FieldDescriptorProto::Label::LABEL_REQUIRED when :optional then Google::Protobuf::FieldDescriptorProto::Label::LABEL_OPTIONAL when :repeated then 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 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_DOUBLE when :float then Google::Protobuf::FieldDescriptorProto::Type::TYPE_FLOAT when :int64 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT64 when :unit64 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT64 when :int64 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT32 when :fixed64 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED64 when :fixed32 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED32 when :bool then Google::Protobuf::FieldDescriptorProto::Type::TYPE_BOOL when :string then Google::Protobuf::FieldDescriptorProto::Type::TYPE_STRING when :group then Google::Protobuf::FieldDescriptorProto::Type::TYPE_GROUP when :message then Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE when :bytes then Google::Protobuf::FieldDescriptorProto::Type::TYPE_BYTES when :uint32 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT32 when :enum then Google::Protobuf::FieldDescriptorProto::Type::TYPE_ENUM when :sfixed32 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED32 when :sfixed64 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED64 when :sint32 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT32 when :sint64 then Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT64 else Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE end end |