Class: Spoom::Coverage::D3::CircleMap::Sigils
- Inherits:
-
Spoom::Coverage::D3::CircleMap
- Object
- Base
- Spoom::Coverage::D3::CircleMap
- Spoom::Coverage::D3::CircleMap::Sigils
- Defined in:
- lib/spoom/coverage/d3/circle_map.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(id, file_tree, nodes_strictnesses, nodes_scores) ⇒ Sigils
constructor
: ( | String id, | FileTree file_tree, | Hash[FileTree::Node, String?] nodes_strictnesses, | Hash[FileTree::Node, Float] nodes_scores | ) -> void.
-
#tree_node_to_json(node) ⇒ Object
: (FileTree::Node node) -> Hash[Symbol, untyped].
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
: ( | String id, | FileTree file_tree, | Hash[FileTree::Node, String?] nodes_strictnesses, | Hash[FileTree::Node, Float] nodes_scores | ) -> void
154 155 156 157 158 |
# File 'lib/spoom/coverage/d3/circle_map.rb', line 154 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
: (FileTree::Node node) -> Hash[Symbol, untyped]
161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/spoom/coverage/d3/circle_map.rb', line 161 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 |