Class: DepsGrapher::Layer

Inherits:
Object
  • Object
show all
Defined in:
lib/deps_grapher/layer.rb,
lib/deps_grapher/layer/registry.rb

Defined Under Namespace

Modules: Registry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Layer

Returns a new instance of Layer.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/deps_grapher/layer.rb', line 28

def initialize(&block)
  @visible = true
  DSL.new(self).instance_eval(&block)

  assert!

  return if default?

  source.files.each do |file|
    Registry.register file, self
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/deps_grapher/layer.rb', line 26

def name
  @name
end

#visibleObject

Returns the value of attribute visible.



26
27
28
# File 'lib/deps_grapher/layer.rb', line 26

def visible
  @visible
end

Class Method Details

.exist?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/deps_grapher/layer.rb', line 21

def exist?(file_path)
  Registry.exist? file_path
end

.fetch(file_path) ⇒ Object



9
10
11
# File 'lib/deps_grapher/layer.rb', line 9

def fetch(file_path)
  Registry.fetch file_path
end

.namesObject



13
14
15
# File 'lib/deps_grapher/layer.rb', line 13

def names
  Registry.all.to_set(&:name)
end

.visible_namesObject



17
18
19
# File 'lib/deps_grapher/layer.rb', line 17

def visible_names
  Registry.all.select(&:visible).to_set(&:name)
end

Instance Method Details

#color(&block) ⇒ Object



46
47
48
49
# File 'lib/deps_grapher/layer.rb', line 46

def color(&block)
  @color_defined = true if block
  Visualizer::Color.new(name, &block)
end

#source(&block) ⇒ Object



41
42
43
44
# File 'lib/deps_grapher/layer.rb', line 41

def source(&block)
  @source_defined = true if block
  @source ||= Source.new(name, &block)
end