Sha256: e2a779d8a59ec4986e04d56e265bc94c9882d7fa4617590e757cbfb8b54773c1

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

require 'rgl/adjacency'
require 'rgl/dot'

module RomSqlGraph
  class Base
    attr_reader :repo

    def initialize(repo)
      @repo = repo
    end

    def edges
      Edges.new(repo).to_a
    end
    alias_method :to_a, :edges

    def generate_image
      graph.write_to_graphic_file('jpg')
    end

    def generate_html
      HtmlGeneration.new(edges).call
    end

    def to_s
      graph.edges.sort.to_s
    end

  private

    def graph
      if @graph.nil?
        @graph ||= RGL::DirectedAdjacencyGraph[]
        to_a.each { |edge| graph.add_edge(*edge) }
      end

      @graph
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom_sql_graph-0.2.0 lib/rom_sql_graph/base.rb