Class: Spoom::Coverage::D3::CircleMap::Sigils

Inherits:
Spoom::Coverage::D3::CircleMap show all
Extended by:
T::Sig
Defined in:
lib/spoom/coverage/d3/circle_map.rb

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Spoom::Coverage::D3::CircleMap

header_script, header_style, #script

Methods inherited from Base

header_script, header_style, #html, #script, #tooltip

Constructor Details

#initialize(id, file_tree, nodes_strictnesses, nodes_scores) ⇒ Sigils

Returns a new instance of Sigils.



159
160
161
162
163
# File 'lib/spoom/coverage/d3/circle_map.rb', line 159

def initialize(id, file_tree, nodes_strictnesses, nodes_scores)
  @nodes_strictnesses = nodes_strictnesses
  @nodes_scores = nodes_scores
  super(id, file_tree.roots.map { |r| tree_node_to_json(r) })
end

Instance Method Details

#tree_node_to_json(node) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/spoom/coverage/d3/circle_map.rb', line 166

def tree_node_to_json(node)
  if node.children.empty?
    {
      name: node.name,
      strictness: @nodes_strictnesses.fetch(node, "false"),
    }
  else
    {
      name: node.name,
      children: node.children.values.map { |n| tree_node_to_json(n) },
      score: @nodes_scores.fetch(node, 0.0),
    }
  end
end