class Symbol
Public Instance Methods
to_postscript()
click to toggle source
Convert this symbol into a PostScript expression evaluating to a PostScript name object. If the string does not look like a PostScript name, the resulting expression will use the [[cvn]] operator to convert a PostScript string into a PostScript name.
# File lib/pson.rb, line 52 def to_postscript s = self.to_s # Does this symbol parse cleanly if treated as a PostScript name? # We're deliberately conservative here. if s.unpack('C*').all?{ |cp| [ 0x30 .. 0x39, # digits 0x41 .. 0x5A, # uppercase 0x61 .. 0x7A, # lowercase "-_", # special ].any?{ |range| range.include? cp}} then return '/' + s else # If not, represent the symbol as a string and convert it to name in # PostScript. return s.to_postscript + " cvn" end end