Class: Protobuf::Node::ProtoNode
- Defined in:
- lib/protobuf/compiler/nodes.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #accept_descriptor_visitor(visitor) ⇒ Object
- #accept_message_visitor(visitor) ⇒ Object
- #accept_rpc_visitor(visitor) ⇒ Object
-
#initialize(children) ⇒ ProtoNode
constructor
A new instance of ProtoNode.
Methods inherited from Base
Constructor Details
#initialize(children) ⇒ ProtoNode
Returns a new instance of ProtoNode.
24 25 26 |
# File 'lib/protobuf/compiler/nodes.rb', line 24 def initialize(children) @children = children || [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
22 23 24 |
# File 'lib/protobuf/compiler/nodes.rb', line 22 def children @children end |
Instance Method Details
#accept_descriptor_visitor(visitor) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/protobuf/compiler/nodes.rb', line 45 def accept_descriptor_visitor(visitor) descriptor = Google::Protobuf::FileDescriptorProto.new(:name => visitor.filename) visitor.file_descriptor = descriptor visitor.in_context(descriptor) do @children.each {|child| child.accept_descriptor_visitor(visitor) } end end |
#accept_message_visitor(visitor) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/protobuf/compiler/nodes.rb', line 28 def (visitor) visitor.write('### Generated by rprotoc. DO NOT EDIT!') visitor.write("### <proto file: #{visitor.proto_file}>") if visitor.attach_proto? visitor.write(visitor.commented_proto_contents) if visitor.attach_proto? visitor.write(<<-EOS) require 'protobuf/message/message' require 'protobuf/message/enum' require 'protobuf/message/extend' EOS @children.each {|child| child.(visitor) } visitor.close_ruby end |
#accept_rpc_visitor(visitor) ⇒ Object
41 42 43 |
# File 'lib/protobuf/compiler/nodes.rb', line 41 def accept_rpc_visitor(visitor) @children.each {|child| child.accept_rpc_visitor(visitor) } end |