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.
151 152 153 |
# File 'lib/protobuf/compiler/nodes.rb', line 151 def initialize(name, children) @name, @children = name, children end |
Instance Method Details
#accept_descriptor_visitor(visitor) ⇒ Object
164 165 166 167 168 169 170 |
# File 'lib/protobuf/compiler/nodes.rb', line 164 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
155 156 157 158 159 160 161 162 |
# File 'lib/protobuf/compiler/nodes.rb', line 155 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 |