Class: DepsGrapher::Visualizer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/deps_grapher/visualizer/base.rb

Direct Known Subclasses

Cytoscape, DepsGrapher::Vis

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(downloader, options) ⇒ Base

Returns a new instance of Base.



18
19
20
21
22
23
# File 'lib/deps_grapher/visualizer/base.rb', line 18

def initialize(downloader, options)
  @downloader = downloader
  @options = options
  @nodes = []
  @edges = []
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/deps_grapher/visualizer/base.rb', line 16

def options
  @options
end

Class Method Details

.command_option(name, default: false) ⇒ Object



11
12
13
# File 'lib/deps_grapher/visualizer/base.rb', line 11

def command_option(name, default: false)
  Registry.register self, CommandOption.new(name, default)
end

Instance Method Details

#accept!(nodes, edges) ⇒ Object



25
26
27
28
29
# File 'lib/deps_grapher/visualizer/base.rb', line 25

def accept!(nodes, edges)
  @nodes = nodes
  @edges = edges
  self
end

#renderObject



31
32
33
34
35
36
37
# File 'lib/deps_grapher/visualizer/base.rb', line 31

def render
  required_js.each do |url|
    @downloader.download url
  end

  ERB.new(File.read(template_path), trim_mode: "-").result(binding)
end