Class: Protobuf::Node::ExtendNode

Inherits:
Base
  • Object
show all
Defined in:
lib/protobuf/compiler/nodes.rb

Instance Method Summary collapse

Methods inherited from Base

#accept_rpc_visitor, #define_in_the_file

Constructor Details

#initialize(name, children) ⇒ ExtendNode

Returns a new instance of ExtendNode.



129
130
131
# File 'lib/protobuf/compiler/nodes.rb', line 129

def initialize(name, children)
  @name, @children = name, children
end

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



143
144
145
# File 'lib/protobuf/compiler/nodes.rb', line 143

def accept_descriptor_visitor(visitor)
  # TODO: how should i handle this?
end

#accept_message_visitor(visitor) ⇒ Object



133
134
135
136
137
138
139
140
141
# File 'lib/protobuf/compiler/nodes.rb', line 133

def accept_message_visitor(visitor)
  name = @name.is_a?(Array) ? @name.join : name.to_s
  visitor.write "class #{name} < ::Protobuf::Message"
  visitor.in_context self.class do 
    define_in_the_file visitor
    @children.each {|child| child.accept_message_visitor visitor}
  end
  visitor.write "end"
end