class RGL::DOT::Element
Ancestor of Edge, Node, and Graph.
def initialize(params = {}, option_list = [])
def initialize(params = {}, option_list = []) @name = params['name'] ? params['name'] : nil @options = {} option_list.each do |i| @options[i] = params[i] if params[i] end end
def quote_ID(id)
characters are escaped as necessary.
Returns the string given in _id_ within quotes if necessary. Special
def quote_ID(id) # Ensure that the ID is a string. id = id.to_s # Return the ID verbatim if it looks like a name, a number, or HTML. return id if id =~ /\A([[:alpha:]_][[:alnum:]_]*|-?(\.[[:digit:]]+|[[:digit:]]+(\.[[:digit:]]*)?)|<.*>)\Z/m && id[-1] != ?\n # Return a quoted version of the ID otherwise. '"' + id.gsub('\\', '\\\\\\\\').gsub('"', '\\\\"') + '"' end
def quote_label(label)
into the new string verbatim.
order to handle embedded *\n*, *\r*, and *\l* sequences which are copied
characters are escaped as necessary. Labels get special treatment in
Returns the string given in _label_ within quotes if necessary. Special
def quote_label(label) # Ensure that the label is a string. label = label.to_s # Return the label verbatim if it looks like a name, a number, or HTML. return label if label =~ /\A([[:alpha:]_][[:alnum:]_]*|-?(\.[[:digit:]]+|[[:digit:]]+(\.[[:digit:]]*)?)|<.*>)\Z/m && label[-1] != ?\n # Return a quoted version of the label otherwise. '"' + label.split(/(\\n|\\r|\\l)/).collect do |part| case part when "\\n", "\\r", "\\l" part else part.gsub('\\', '\\\\\\\\').gsub('"', '\\\\"').gsub("\n", '\\n') end end.join + '"' end