Class: Eatr::DotGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/eatr/dot_generator.rb

Constant Summary collapse

DEFAULT_TEMPLATE_PATH =
"#{File.dirname(__FILE__)}/dot_template.dot"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_paths, template_path: DEFAULT_TEMPLATE_PATH) ⇒ DotGenerator

Returns a new instance of DotGenerator.



7
8
9
10
# File 'lib/eatr/dot_generator.rb', line 7

def initialize(schema_paths, template_path: DEFAULT_TEMPLATE_PATH)
  @tables = Array[schema_paths].flatten.map { |s| Schema.new(YAML.load(File.read(s))) }
  @template_path = template_path
end

Instance Attribute Details

#tablesObject (readonly)

Returns the value of attribute tables.



3
4
5
# File 'lib/eatr/dot_generator.rb', line 3

def tables
  @tables
end

Instance Method Details

#to_dotObject



12
13
14
# File 'lib/eatr/dot_generator.rb', line 12

def to_dot
  ERB.new(File.read(@template_path), nil, '-').result(binding)
end