Class: Dogviz::Container

Inherits:
Object
  • Object
show all
Includes:
Common, Nominator, Parent
Defined in:
lib/dogviz/container.rb

Direct Known Subclasses

LogicalContainer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parent

#add, #container, #find, #find_all, #group, #logical_container, #root?, #thing

Methods included from Nominator

#nominate, #nominate_from

Methods included from Common

#ancestors, #create_id, #doclink, #in_rollup?, #in_skip?, #info, #inherited_render_options, #label_with_info, #on_top_rollup?, #rollup!, #rollup?, #root, #setup_render_attributes, #skip!, #skip?, #under_rollup?, #under_skip?

Constructor Details

#initialize(parent, name, options = {}) ⇒ Container

Returns a new instance of Container.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dogviz/container.rb', line 14

def initialize(parent, name, options = {})
  @children = []
  @by_name = Registry.new name
  @parent = parent
  @name = name
  @id = create_id(name, parent)
  @skip = false
  @info = {}

  init_rollup options

  setup_render_attributes label: name
  default_bounded_option(options)

  @render_options = options.merge(inherited_render_options)

  parent.register name, self
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



12
13
14
# File 'lib/dogviz/container.rb', line 12

def children
  @children
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/dogviz/container.rb', line 12

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/dogviz/container.rb', line 12

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



12
13
14
# File 'lib/dogviz/container.rb', line 12

def node
  @node
end

#parentObject (readonly)

Returns the value of attribute parent.



11
12
13
# File 'lib/dogviz/container.rb', line 11

def parent
  @parent
end

#render_optionsObject (readonly)

Returns the value of attribute render_options.



12
13
14
# File 'lib/dogviz/container.rb', line 12

def render_options
  @render_options
end

#render_typeObject (readonly)

Returns the value of attribute render_type.



12
13
14
# File 'lib/dogviz/container.rb', line 12

def render_type
  @render_type
end

Instance Method Details

#auto_nominate?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/dogviz/container.rb', line 56

def auto_nominate?
  root.auto_nominate?
end

#register(name, thing) ⇒ Object



33
34
35
36
# File 'lib/dogviz/container.rb', line 33

def register(name, thing)
  @by_name.register name, thing
  parent.register name, thing
end

#render(renderer) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dogviz/container.rb', line 38

def render(renderer)
  if on_top_rollup?
    do_render_node renderer
  elsif !under_rollup?
    do_render_subgraph renderer
  end

  children.each { |c|
    c.render renderer
  }
end

#render_edges(renderer) ⇒ Object



50
51
52
53
54
# File 'lib/dogviz/container.rb', line 50

def render_edges(renderer)
  children.each { |c|
    c.render_edges renderer
  }
end