Write out definition node using ruby def

 @param node [Node] Current node data with options
438298
def define(node)
      # Write out def method_name
      definition = "def _opulent_definition_#{node[@value].to_s.tr '-', '_'}"

      # Node attributes
      parameters = []
      node[@options][:parameters].each do |key, value|
        parameters << "#{key} = #{value[@value]}"
      end
      parameters << 'attributes = {}'
      parameters << 'indent'
      parameters << '&block'
      definition += '(' + parameters.join(', ') + ')'

      buffer_eval 'instance_eval do'
      buffer_eval definition

      @in_definition = true
      node[@children].each do |child|
        root child, 0
      end
      @in_definition = false

      buffer_eval 'end'
      buffer_eval 'end'
    end
735901
def node_to_ini(node, output=sys.stdout):
    
    for subnode in node:
        output.write(u'\n[%s]\n' % subnode.tag)
        for name, value in sorted(subnode.attrib.items()):
            output.write(u'%s=%s\n' % (name, value))
    output.flush()
1017864
private void printChildDeclaration(NodeDefinitionData nodeDefinition, OutputStreamWriter out) throws IOException,
      RepositoryException
   {
      out.write("\r\n  ");
      out.write("+ " + qNameToString(nodeDefinition.getName()) + " ");

      InternalQName[] requiredTypes = nodeDefinition.getRequiredPrimaryTypes();
      if (requiredTypes != null && requiredTypes.length > 0)
      {
         /** if there is only 1 element and it is NT_BASE then avoid printing it */
         if (requiredTypes.length > 1 || !requiredTypes[0].equals(Constants.NT_BASE))
         {
            out.write("(" + qNameToString(requiredTypes[0]));
            for (int i = 1; i < requiredTypes.length; i++)
            {
               out.write(", " + qNameToString(requiredTypes[i]));
            }
            out.write(")");
         }
      }

      if (nodeDefinition.getDefaultPrimaryType() != null)
      {
         out.write("\r\n    = " + qNameToString(nodeDefinition.getDefaultPrimaryType()));
      }

      StringBuilder attributes = new StringBuilder();

      if (nodeDefinition.isAutoCreated())
      {
         attributes.append("autocreated ");
      }
      if (nodeDefinition.isMandatory())
      {
         attributes.append("mandatory ");
      }
      if (nodeDefinition.isProtected())
      {
         attributes.append("protected ");
      }
      if (nodeDefinition.isAllowsSameNameSiblings())
      {
         attributes.append("sns ");
      }

      if (nodeDefinition.getOnParentVersion() != OnParentVersionAction.COPY)
      {
         attributes.append("\r\n    " + OnParentVersionAction.nameFromValue(nodeDefinition.getOnParentVersion()) + " ");
      }

      if (attributes.length() > 0)
      {
         out.write("\r\n    ");
         out.write(attributes.toString());
      }

   }
992884
def define_module(node, definition_builder, options = {})
      builder    = definition_builder.new(node, self, options)
      definition = builder.build
      scope      = builder.scope
      existing   = scope.lookup(definition.type, definition.name, false)

      if existing
        definition = existing

        inherit_definition(definition, current_scope)
      else
        definition.add_definition(definition)

        scope.add_definition(definition)
      end

      associate_node(node, definition)

      push_scope(definition)
    end
487659
def rewritten_code
      if rewritten_source.split("\n").length > 1
        "\n\n" + rewritten_source.split("\n").map { |line|
          indent(@node) + line
        }.join("\n")
      else
        "\n" + indent(@node) + rewritten_source
      end
    end
714209
def write_attr(attr_name, value, to_call = nil)
      self[attr_name] = value && to_call ? value.__send__(to_call) : value
    end
651651
def delimited(nodes, &block)
      return if nodes.empty?

      block ||= method(:visit)
      head, *tail = nodes
      block.call(head)
      tail.each do |node|
        write(DEFAULT_DELIMITER)
        block.call(node)
      end
    end
331930
def htmlify_except(nodes)
      nodes.reduce(to_html) do |output, node|
        output.gsub(node.to_html, node.to_xhtml)
      end
    end
312725
function writeNode(node, c, end) {
      var toYield = [];
      forEach(simplifyDOM(node, end), function(part) {
        toYield.push(insertPart(part));
      });
      return yield(toYield.join(""), c);
    }
627033
private void rewriteDefinition(Node definitionSite, String newMethodName) {
    final Node function;
    final Node subtreeToRemove;
    final Node nameSource;

    switch (definitionSite.getToken()) {
      case GETPROP:
        function = definitionSite.getParent().getLastChild();
        nameSource = definitionSite.getLastChild();
        subtreeToRemove = NodeUtil.getEnclosingStatement(definitionSite);
        break;

      case STRING_KEY:
      case MEMBER_FUNCTION_DEF:
        function = definitionSite.getLastChild();
        nameSource = definitionSite;
        subtreeToRemove = definitionSite;
        break;

      default:
        throw new IllegalArgumentException(definitionSite.toString());
    }

    // Define a new variable after the original declaration.
    Node statement = NodeUtil.getEnclosingStatement(definitionSite);
    Node newNameNode = IR.name(newMethodName).useSourceInfoIfMissingFrom(nameSource);
    Node newVarNode = IR.var(newNameNode).useSourceInfoIfMissingFrom(nameSource);
    statement.getParent().addChildBefore(newVarNode, statement);

    // Attatch the function to the new variable.
    function.detach();
    newNameNode.addChildToFront(function);

    // Create the `this` param.
    String selfName = newMethodName + "$self";
    Node paramList = function.getSecondChild();
    paramList.addChildToFront(IR.name(selfName).useSourceInfoIfMissingFrom(function));
    compiler.reportChangeToEnclosingScope(paramList);

    // Eliminate `this`.
    replaceReferencesToThis(function.getSecondChild(), selfName); // In default param values.
    replaceReferencesToThis(function.getLastChild(), selfName); // In function body.

    fixFunctionType(function);

    // Clean up dangling AST.
    NodeUtil.deleteNode(subtreeToRemove, compiler);
    compiler.reportChangeToEnclosingScope(newVarNode);
  }
801530
private static void print(Node node, PrintWriter out) {
        if (node == null) {
            return;
        }

        boolean hasChildren = false;
        int type = node.getNodeType();
        NodeList children = null;
        switch (type) {
            case Node.DOCUMENT_NODE:
                children = node.getChildNodes();
                if (children != null) {
                    int numChildren = children.getLength();
                    for (int i = 0; i < numChildren; i++) {
                        print(children.item(i), out);
                    }
                }
                break;
            case Node.ELEMENT_NODE:
                out.print('<');
                out.print(node.getNodeName());
                if (node.hasAttributes()) {
                    NamedNodeMap attrs = node.getAttributes();
                    int len = (attrs != null) ? attrs.getLength() : 0;
                    for (int a = 0; a < len; a++) {
                        Attr attr = (Attr) attrs.item(a);
                        out.print(' ');
                        out.print(attr.getNodeName());
                        out.print("=\"");
                        out.print(attr.getValue());
                        out.print('\"');
                    }
                }
                children = node.getChildNodes();
                if (children != null) {
                    int numChildren = children.getLength();
                    hasChildren = (numChildren > 0);
                    if (hasChildren) {
                        out.print('>');
                    }
                    for (int i = 0; i < numChildren; i++) {
                        print(children.item(i), out);
                    }
                } else {
                    hasChildren = false;
                }
                if (!hasChildren) {
                    out.print("/>");
                }
                break;
            case Node.ENTITY_REFERENCE_NODE:
                out.print('&');
                out.print(node.getNodeName());
                out.print(';');
                break;
            case Node.CDATA_SECTION_NODE:
                out.print("<![CDATA[");
                out.print(node.getNodeValue());
                out.print("]]>");
                break;
            case Node.TEXT_NODE:
                out.print(node.getNodeValue());
                break;
            default:
                if (logger.isDebugEnabled()) {
                    logger.debug("Unknown type: " + type);
                }
        }
        if (type == Node.ELEMENT_NODE && hasChildren) {
            out.print("</");
            out.print(node.getNodeName());
            out.print('>');
            hasChildren = false;
        }
    }
1298540
private void writeNode(Node node) {
        try {
            this.pStmtNodesC.setLong(1, node.getId());
            this.pStmtNodesC.setDouble(2, node.getLatitude());
            this.pStmtNodesC.setDouble(3, node.getLongitude());

            this.pStmtNodesC.addBatch();

            if (this.nNodes % BATCH_LIMIT == 0) {
                this.pStmtNodesC.executeBatch();

                this.pStmtNodesC.clearBatch();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
557093
def visit_tag(current_node)
      attributes = formatted_attributes(current_node)
      children_wo_attributes = (current_node.children - current_node.attributes)

      text = "<#{current_node.name}"

      text += attributes.to_s unless attributes.empty?

      other_than_new_lines = children_wo_attributes.any? { |n| n.type != :newline }

      text += if other_than_new_lines
                '>'
              else
                '/>'
              end

      conditional_nodes = current_node.children.select { |n| n.type == :output && n.conditional }

      unless conditional_nodes.empty?
        buff_code "if (#{conditional_nodes.map(&:value).join(') && (')})"

        @code_indent += 1
      end

      buff_print_text(text, new_line: true, indent: true)

      if other_than_new_lines
        last_node = children_wo_attributes.last
        is_last_newline = !last_node.nil? && last_node.type == :newline
        nodes = if is_last_newline
                  children_wo_attributes[0...-1]
                else
                  children_wo_attributes
                end

        code_indent do
          visit_nodes(nodes)
        end

        buff_print_text("</#{current_node.name}>", new_line: true, indent: true)

        # print new line after the tag
        visit_node(last_node) if is_last_newline
      end

      unless conditional_nodes.empty? # rubocop:disable Style/GuardClause
        @code_indent -= 1

        buff_code 'end'
      end
    end
837898
private void writeMethods(Definition def, Writer out, int indent) throws IOException
   {
      if (def.getMcfDefs().get(0).isDefineMethodInConnection())
      {
         if (def.getMcfDefs().get(0).getMethods().size() > 0)
         {
            for (MethodForConnection method : def.getMcfDefs().get(0).getMethods())
            {
               writeMethodSignature(out, indent, method);

               writeLeftCurlyBracket(out, indent);
               writeIndent(out, indent + 1);
               if (!method.getReturnType().equals("void"))
               {
                  out.write("return ");
               }
               out.write("getConnection()." + method.getMethodName() + "(");
               int paramSize = method.getParams().size();
               for (int i = 0; i < paramSize; i++)
               {
                  MethodParam param = method.getParams().get(i);
                  out.write(param.getName());
                  if (i + 1 < paramSize)
                     out.write(", ");
               }
               out.write(");\n");

               writeRightCurlyBracket(out, indent);
            }
         }
      }
      else
      {
         writeSimpleMethodSignature(out, indent, " * Call me", "public void callMe()");
         writeLeftCurlyBracket(out, indent);
         writeWithIndent(out, indent + 1, "try");
         writeLeftCurlyBracket(out, indent + 1);
         writeWithIndent(out, indent + 2, "getConnection().callMe();");
         writeRightCurlyBracket(out, indent + 1);
         writeWithIndent(out, indent + 1, "catch (Exception e)");
         writeLeftCurlyBracket(out, indent + 1);
         writeRightCurlyBracket(out, indent + 1);
         writeRightCurlyBracket(out, indent);
      }
   }
677685
def on_sclass(node)
      parent       = node.children[0]
      definition   = evaluate_node(parent)
      @method_type = definition.method_call_type

      associate_node(node, definition)

      push_scope(definition)
    end
909900
def output(data = {}, indent = 0)
      case @options['format']
      when 'json'
        puts JSON.pretty_generate(data)
      when 'yaml'
        puts data.to_yaml
      else
        # rubocop:disable Metrics/BlockNesting
        if data.class == Hash
          data.each do |k, v|
            if v.class == Hash || v.class == Array
              puts "#{' ' * indent}#{k.nil? ? 'nil' : k}:"
              output(v, indent + 2)
            else
              puts "#{' ' * indent}#{k.nil? ? 'nil' : k}: #{v.nil? ? 'nil' : v}"
            end
          end
        elsif data.class == Array
          data.each do |d|
            if d.class == Hash || d.class == Array
              output(d, indent + 2)
            else
              puts "#{' ' * indent}#{d.nil? ? 'nil' : d}"
            end
          end
          puts "\nTotal: #{data.size}" if indent < 1
        else
          puts "#{' ' * indent}#{data.nil? ? 'nil' : data}"
        end
        # rubocop:enable Metrics/BlockNesting
      end
    end
255208
def on_def(node)
      receiver = nil

      if node.type == :defs
        receiver = evaluate_node(node.children[0])
      end

      builder = DefinitionBuilder::RubyMethod.new(
        node,
        self,
        :type       => @method_type,
        :receiver   => receiver,
        :visibility => @visibility
      )

      definition = builder.build

      builder.scope.add_definition(definition)

      associate_node(node, definition)

      buffer_docstring_tags(node)

      if docstring_tags and docstring_tags.return_tag
        assign_return_value_from_tag(
          docstring_tags.return_tag,
          definition
        )
      end

      push_scope(definition)
    end