Sha256: cf67ada70f23fdeaddd5695ea8494c9ddfbe869a0428aed36c557e109290fd53

Contents?: true

Size: 543 Bytes

Versions: 1

Compression:

Stored size: 543 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 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.1.0 lib/rom_sql_graph/base.rb