class RGL::DOT::Element
Attributes
Public Class Methods
Source
# File lib/rgl/rdot.rb 196 def initialize(params = {}, option_list = []) 197 @name = params['name'] ? params['name'] : nil 198 @options = {} 199 200 option_list.each do |i| 201 @options[i] = params[i] if params[i] 202 end 203 end
Private Instance Methods
Source
# File lib/rgl/rdot.rb 210 def quote_ID(id) 211 # Ensure that the ID is a string. 212 id = id.to_s 213 214 # Return the ID verbatim if it looks like a name, a number, or HTML. 215 return id if id =~ /\A([[:alpha:]_][[:alnum:]_]*|-?(\.[[:digit:]]+|[[:digit:]]+(\.[[:digit:]]*)?)|<.*>)\Z/m && id[-1] != ?\n 216 217 # Return a quoted version of the ID otherwise. 218 '"' + id.gsub('\\', '\\\\\\\\').gsub('"', '\\\\"') + '"' 219 end
Returns the string given in id within quotes if necessary. Special characters are escaped as necessary.
Source
# File lib/rgl/rdot.rb 226 def quote_label(label) 227 # Ensure that the label is a string. 228 label = label.to_s 229 230 # Return the label verbatim if it looks like a name, a number, or HTML. 231 return label if label =~ /\A([[:alpha:]_][[:alnum:]_]*|-?(\.[[:digit:]]+|[[:digit:]]+(\.[[:digit:]]*)?)|<.*>)\Z/m && label[-1] != ?\n 232 233 # Return a quoted version of the label otherwise. 234 '"' + label.split(/(\\n|\\r|\\l)/).collect do |part| 235 case part 236 when "\\n", "\\r", "\\l" 237 part 238 else 239 part.gsub('\\', '\\\\\\\\').gsub('"', '\\\\"').gsub("\n", '\\n') 240 end 241 end.join + '"' 242 end
Returns the string given in label within quotes if necessary. Special characters are escaped as necessary. Labels get special treatment in order to handle embedded n, r, and l sequences which are copied into the new string verbatim.