Class: Pgerd::Erd

Inherits:
Object
  • Object
show all
Defined in:
lib/pgerd/erd.rb,
lib/pgerd/erd/view_node.rb,
lib/pgerd/erd/table_node.rb

Defined Under Namespace

Classes: TableNode, ViewNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, options = {}) ⇒ Erd

Returns a new instance of Erd.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pgerd/erd.rb', line 10

def initialize(database, options = {})
  @database = database
  @title = options[:title] || @database.name
  @size = options[:size].to_s.downcase
  @options = options

  create_a_digraph
  draw_the_tables
  draw_the_views
  draw_the_foreign_keys
end

Instance Attribute Details

#diagramObject (readonly)

Returns the value of attribute diagram.



8
9
10
# File 'lib/pgerd/erd.rb', line 8

def diagram
  @diagram
end

Instance Method Details

#a4?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/pgerd/erd.rb', line 26

def a4?
  @size == 'a4'
end

#to_sObject



22
23
24
# File 'lib/pgerd/erd.rb', line 22

def to_s
  @diagram.output(dot: String)
end