Class: DepsGrapher::Visualizer::Color

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

Defined Under Namespace

Modules: Registry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layer_name, &block) ⇒ Color

Returns a new instance of Color.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/deps_grapher/visualizer/color.rb', line 21

def initialize(layer_name, &block)
  DSL.new(self).instance_eval(&block)

  @layer_name = layer_name
  @font ||= "#fff"

  assert!

  @settings = {
    background: background,
    border: border,
    font: font,
    highlight: {
      background: background,
      border: border,
      font: font
    }
  }

  Registry.register layer_name, self
end

Instance Attribute Details

#arrowObject

Returns the value of attribute arrow.



19
20
21
# File 'lib/deps_grapher/visualizer/color.rb', line 19

def arrow
  @arrow
end

#backgroundObject

Returns the value of attribute background.



19
20
21
# File 'lib/deps_grapher/visualizer/color.rb', line 19

def background
  @background
end

#borderObject

Returns the value of attribute border.



19
20
21
# File 'lib/deps_grapher/visualizer/color.rb', line 19

def border
  @border
end

#fontObject

Returns the value of attribute font.



19
20
21
# File 'lib/deps_grapher/visualizer/color.rb', line 19

def font
  @font
end

#layer_nameObject

Returns the value of attribute layer_name.



19
20
21
# File 'lib/deps_grapher/visualizer/color.rb', line 19

def layer_name
  @layer_name
end

#settingsObject

Returns the value of attribute settings.



19
20
21
# File 'lib/deps_grapher/visualizer/color.rb', line 19

def settings
  @settings
end

Class Method Details

.fetch(layer_name) ⇒ Object Also known as: []



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

def fetch(layer_name)
  Registry.fetch layer_name
end

.generate_map(type) ⇒ Object



14
15
16
# File 'lib/deps_grapher/visualizer/color.rb', line 14

def generate_map(type)
  Registry.all.to_h { |color| [color.layer_name, color.send(type)] }
end

Instance Method Details

#highlight(background:, border:, font: "#fff") ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/deps_grapher/visualizer/color.rb', line 43

def highlight(background:, border:, font: "#fff")
  @settings[:highlight] = {
    background: background,
    border: border,
    font: font
  }

  self
end