Class: Erde::HashTransformer
- Inherits:
-
Object
- Object
- Erde::HashTransformer
- Defined in:
- lib/erde/cli.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ HashTransformer
constructor
A new instance of HashTransformer.
- #to_dot ⇒ Object
Constructor Details
#initialize(hash) ⇒ HashTransformer
Returns a new instance of HashTransformer.
26 27 28 |
# File 'lib/erde/cli.rb', line 26 def initialize(hash) @hash = hash end |
Instance Method Details
#to_dot ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/erde/cli.rb', line 30 def to_dot schema_string = "" schema_string << "digraph tables {" schema_string << "node [shape=Mrecord rankdir=LR];" @hash.each_pair do |table_name, table_schema| schema_string << "#{table_name} [label=\"{#{table_name}|#{table_schema['columns'].map {|c| "<#{c}>#{c}" }.join("|")}}\"];" table_schema['relations'].each_pair do |column, target| schema_string << "#{table_name}:#{column} -> #{target['table']}:#{target['column']};" end end schema_string << "}" schema_string end |