Class: Protobuf::Node::EnumNode
- Defined in:
- lib/protobuf/compiler/nodes.rb
Instance Method Summary collapse
- #accept_descriptor_visitor(visitor) ⇒ Object
- #accept_message_visitor(visitor) ⇒ Object
-
#initialize(name, children) ⇒ EnumNode
constructor
A new instance of EnumNode.
Methods inherited from Base
#accept_rpc_visitor, #define_in_the_file
Constructor Details
#initialize(name, children) ⇒ EnumNode
Returns a new instance of EnumNode.
150 151 152 |
# File 'lib/protobuf/compiler/nodes.rb', line 150 def initialize(name, children) @name, @children = name, children end |
Instance Method Details
#accept_descriptor_visitor(visitor) ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/protobuf/compiler/nodes.rb', line 163 def accept_descriptor_visitor(visitor) descriptor = Google::Protobuf::EnumDescriptorProto.new(:name => @name.to_s) visitor.enum_descriptor = descriptor visitor.in_context(descriptor) do @children.each {|child| child.accept_descriptor_visitor(visitor) } end end |
#accept_message_visitor(visitor) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/protobuf/compiler/nodes.rb', line 154 def (visitor) visitor.write("class #{@name} < ::Protobuf::Enum") visitor.in_context(self.class) do define_in_the_file(visitor) @children.each {|child| child.(visitor) } end visitor.write('end') end |