Class: HDL::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/hdl/loader.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.pathObject



4
5
6
# File 'lib/hdl/loader.rb', line 4

def path
  @path ||= ["."]
end

Class Method Details

.load(name, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hdl/loader.rb', line 9

def load(name, options = {})
  memoize(name, options[:force]) do
    name = name.to_s

    if (d = options[:definition])
      raw = d
      path = nil
    else
      file = file_from_path(name)
      raw  = file.read
      path = file.path
    end

    data = HDL::Parser.parse(raw)

    if data[:table]
      klass = HDL::TableChip
    else
      klass = HDL::SchemaChip
    end

    klass.new(name, path, data)
  end
end