Class: ConceptQL::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/conceptql/graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statement, opts = {}) ⇒ Graph

Returns a new instance of Graph.



10
11
12
13
14
15
16
17
18
# File 'lib/conceptql/graph.rb', line 10

def initialize(statement, opts = {})
  @statement = statement
  @db = opts.fetch(:db, nil)
  @dangler = opts.fetch(:dangler, false)
  @tree = opts.fetch(:tree, Tree.new)
  @title = opts.fetch(:title, nil)
  @suffix = opts.fetch(:suffix, 'pdf')
  ConceptQL::Operators::Operator.send(:include, ConceptQL::Behaviors::Dottable)
end

Instance Attribute Details

#danglerObject (readonly)

Returns the value of attribute dangler.



9
10
11
# File 'lib/conceptql/graph.rb', line 9

def dangler
  @dangler
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



9
10
11
# File 'lib/conceptql/graph.rb', line 9

def file_path
  @file_path
end

#gObject (readonly)

Returns the value of attribute g.



9
10
11
# File 'lib/conceptql/graph.rb', line 9

def g
  @g
end

#statementObject (readonly)

Returns the value of attribute statement.



9
10
11
# File 'lib/conceptql/graph.rb', line 9

def statement
  @statement
end

#suffixObject (readonly)

Returns the value of attribute suffix.



9
10
11
# File 'lib/conceptql/graph.rb', line 9

def suffix
  @suffix
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/conceptql/graph.rb', line 9

def title
  @title
end

Instance Method Details

#graphObject



25
26
27
28
29
30
31
# File 'lib/conceptql/graph.rb', line 25

def graph
  @graph ||= begin
    opts = { type: :digraph }
    opts[:label] = title if title
    GraphViz.new(:G, opts)
  end
end

#graph_it(file_path) ⇒ Object



20
21
22
23
# File 'lib/conceptql/graph.rb', line 20

def graph_it(file_path)
  build_graph(g)
  graph.output(suffix.to_sym =>  file_path + ".#{suffix}")
end