Class: Protobuf::Generators::EnumGenerator
- Defined in:
- lib/protobuf/generators/enum_generator.rb
Constant Summary
Constants included from Printable
Printable::PARENT_CLASS_ENUM, Printable::PARENT_CLASS_MESSAGE, Printable::PARENT_CLASS_SERVICE
Instance Attribute Summary
Attributes inherited from Base
#descriptor, #namespace, #options
Instance Method Summary collapse
Methods inherited from Base
#fully_qualified_type_namespace, #initialize, #run_once, #serialize_value, #to_s, #type_namespace, validate_tags
Methods included from Printable
Constructor Details
This class inherits a constructor from Protobuf::Generators::Base
Instance Method Details
#build_value(enum_value_descriptor) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/protobuf/generators/enum_generator.rb', line 30 def build_value(enum_value_descriptor) name = enum_value_descriptor.name name.upcase! if ENV.key?('PB_UPCASE_ENUMS') number = enum_value_descriptor.number "define :#{name}, #{number}" end |
#compile ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/protobuf/generators/enum_generator.rb', line 8 def compile run_once(:compile) do = [] print_class(descriptor.name, :enum) do if descriptor. print OptionGenerator.new(descriptor., current_indent).to_s puts end descriptor.value.each do |enum_value_descriptor| << enum_value_descriptor.number puts build_value(enum_value_descriptor) end end unless descriptor..try(:allow_alias) self.class.(fully_qualified_type_namespace, ) end end end |