# File lib/rgl/rdot.rb, line 242
242:     def to_s (leader = '', indent = '    ')
243:       label_option = nil
244:       if @options['shape'] =~ /^M?record$/ && !@ports.empty? then
245:         # Ignore the given label option in this case since the ports should each
246:         # provide their own name/label.
247:         label_option = leader + indent + "#{quote_ID('label')} = #{quote_ID(@ports.collect { |port| port.to_s }.join(" | "))}"
248:       elsif @options['label'] then
249:         # Otherwise, use the label when given one.
250:         label_option = leader + indent + "#{quote_ID('label')} = #{quote_label(@options['label'])}"
251:       end
252: 
253:       # Convert all the options except `label' and options with nil values
254:       # straight into name = value pairs.  Then toss out any resulting nil
255:       # entries in the final array.
256:       stringified_options = @options.collect do |name, val|
257:         unless name == 'label' || val.nil? then
258:           leader + indent + "#{quote_ID(name)} = #{quote_ID(val)}"
259:         end
260:       end.compact
261:       # Append the specially computed label option.
262:       stringified_options.push(label_option) unless label_option.nil?
263:       # Join them all together.
264:       stringified_options = stringified_options.join(",\n")
265: 
266:       # Put it all together into a single string with indentation and return the
267:       # result.
268:       if stringified_options.empty? then
269:         return leader + quote_ID(@name) unless @name.nil?
270:         return nil
271:       else
272:         return leader + (@name.nil? ? '' : quote_ID(@name) + " ") + "[\n" +
273:           stringified_options + "\n" +
274:           leader + "]"
275:       end
276:     end