Class: Seafoam::Formatters::Json::EdgesFormatter
Overview
A JSON-based formatter for the ‘edges` command.
Instance Attribute Summary
#entry
Instance Method Summary
collapse
#format, #initialize
Instance Method Details
#build_edge(edge) ⇒ Object
40
41
42
|
# File 'lib/seafoam/formatters/json.rb', line 40
def build_edge(edge)
{ from: build_node(edge.from), to: build_node(edge.to), label: edge.props[:label] }
end
|
#build_node(node) ⇒ Object
36
37
38
|
# File 'lib/seafoam/formatters/json.rb', line 36
def build_node(node)
{ id: node.id.to_s, label: node.props[:label] }
end
|
#render_edges_entry(edges) ⇒ Object
21
22
23
|
# File 'lib/seafoam/formatters/json.rb', line 21
def render_edges_entry(edges)
edges.map { |edge| build_edge(edge) }.to_json
end
|
#render_node_entry(node) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/seafoam/formatters/json.rb', line 25
def render_node_entry(node)
{
input: node.inputs.map { |input| build_edge(input) },
output: node.outputs.map { |output| build_edge(output) },
}.to_json
end
|
#render_summary_entry(node_count, edge_count) ⇒ Object
32
33
34
|
# File 'lib/seafoam/formatters/json.rb', line 32
def render_summary_entry(node_count, edge_count)
{ node_count: node_count, edge_count: edge_count }.to_json
end
|