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, #to_s, #type_namespace, validate_tags
Methods included from Printable
Constructor Details
This class inherits a constructor from Protobuf::Generators::Base
Instance Method Details
#allow_alias? ⇒ Boolean
7 8 9 |
# File 'lib/protobuf/generators/enum_generator.rb', line 7 def allow_alias? descriptor..try(:allow_alias!) { false } end |
#build_value(enum_value_descriptor) ⇒ Object
33 34 35 36 37 |
# File 'lib/protobuf/generators/enum_generator.rb', line 33 def build_value(enum_value_descriptor) name = enum_value_descriptor.name number = enum_value_descriptor.number return "define :#{name}, #{number}" end |
#compile ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/protobuf/generators/enum_generator.rb', line 11 def compile run_once(:compile) do = [] print_class(descriptor.name, :enum) do if allow_alias? puts "set_option :allow_alias" puts end descriptor.value.each do |enum_value_descriptor| << enum_value_descriptor.number puts build_value(enum_value_descriptor) end end unless allow_alias? self.class.(fully_qualified_type_namespace, ) end end end |