Sha256: c60e58616a3f0b4ab8ae6a035c6e1d663d906fd1d2ec098abc7ae57e0b5187a3

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

require "rexml/document"

class GraphViz
  class Types
    class LblString < Common
      def check(data)
        return data
      end

      def output
        html = /^<(.*)>$/m.match(@data.to_s)
        if html != nil
          xml = "<gv>" + html[1].to_s + "</gv>"
          begin
            doc = REXML::Document.new(xml)
            unless doc.root.text == html[1].to_s
              "<#{html[1]}>"
            else
              @data.to_s.inspect.gsub( "\\\\", "\\" )
            end
          rescue REXML::ParseException => _
            @data.to_s.inspect.gsub( "\\\\", "\\" )
          end
        else
          @data.to_s.inspect.gsub( "\\\\", "\\" )
        end
      end

      alias :to_gv :output
      alias :to_s :output
      alias :to_ruby :output
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-graphviz-1.2.5 lib/graphviz/types/lbl_string.rb
ruby-graphviz-1.2.4 lib/graphviz/types/lbl_string.rb
ruby-graphviz-1.2.3 lib/graphviz/types/lbl_string.rb
ruby-graphviz-1.2.2 lib/graphviz/types/lbl_string.rb
ruby-graphviz-1.2.1 lib/graphviz/types/lbl_string.rb
ruby-graphviz-1.2.0 lib/graphviz/types/lbl_string.rb