Class: Sequel::ToDot

Inherits:
Object show all
Defined in:
lib/sequel/extensions/to_dot.rb

Defined Under Namespace

Modules: DatasetMethods

Constant Summary

TO_DOT_OPTIONS =

The option keys that should be included in the dot output.

[:with, :distinct, :select, :from, :join, :where, :group, :having, :compounds, :order, :limit, :offset, :lock].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ds) ⇒ ToDot

Given a Dataset, parse the internal structure to generate a dataset visualization.



33
34
35
36
37
38
39
# File 'lib/sequel/extensions/to_dot.rb', line 33

def initialize(ds)
  @i = 0
  @stack = [@i]
  @dot = ["digraph G {", "0 [label=\"self\"];"]
  v(ds, "")
  @dot << "}"
end

Class Method Details

.output(ds) ⇒ Object

Given a Dataset, return a string in dot format that will generate a visualization of the dataset.



27
28
29
# File 'lib/sequel/extensions/to_dot.rb', line 27

def self.output(ds)
  new(ds).output
end

Instance Method Details

#outputObject

Output the dataset visualization as a string in dot format.



42
43
44
# File 'lib/sequel/extensions/to_dot.rb', line 42

def output
  @dot.join("\n")
end