Class: Seafoam::Formatters::Text::EdgesFormatter

Inherits:
Base::EdgesFormatter show all
Defined in:
lib/seafoam/formatters/text.rb

Overview

A plain-text formatter for the ‘edges` command.

Instance Attribute Summary

Attributes inherited from Base::EdgesFormatter

#entry

Instance Method Summary collapse

Methods inherited from Base::EdgesFormatter

#format, #initialize

Constructor Details

This class inherits a constructor from Seafoam::Formatters::Base::EdgesFormatter

Instance Method Details

#render_edges_entry(edges) ⇒ Object



19
20
21
22
23
# File 'lib/seafoam/formatters/text.rb', line 19

def render_edges_entry(edges)
  edges.map do |edge|
    "#{edge.from.id_and_label} ->(#{edge.props[:label]}) #{edge.to.id_and_label}"
  end.join("\n")
end

#render_node_entry(node) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/seafoam/formatters/text.rb', line 25

def render_node_entry(node)
  ret = ["Input:"]
  ret += node.inputs.map do |input|
    "  #{node.id_and_label} <-(#{input.props[:label]}) #{input.from.id_and_label}"
  end

  ret << "Output:"
  ret += node.outputs.map do |output|
    "  #{node.id_and_label} ->(#{output.props[:label]}) #{output.to.id_and_label}"
  end

  ret.join("\n")
end

#render_summary_entry(node_count, edge_count) ⇒ Object



39
40
41
# File 'lib/seafoam/formatters/text.rb', line 39

def render_summary_entry(node_count, edge_count)
  "#{node_count} nodes, #{edge_count} edges"
end