Class: Seafoam::Formatters::Json::DescribeFormatter

Inherits:
Base::DescribeFormatter show all
Defined in:
lib/seafoam/formatters/json.rb

Overview

A JSON-based formatter for the ‘describe` command.

Instance Attribute Summary

Attributes inherited from Base::DescribeFormatter

#description, #graph

Instance Method Summary collapse

Methods inherited from Base::DescribeFormatter

#initialize

Constructor Details

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

Instance Method Details

#formatObject



10
11
12
13
14
15
16
# File 'lib/seafoam/formatters/json.rb', line 10

def format
  ret = Seafoam::Graal::GraphDescription::ATTRIBUTES.map { |attr| [attr, description.send(attr)] }.to_h
  ret[:node_count] = graph.nodes.values.count { |n| !n.props[:hidden] }
  ret[:node_counts] = description.sorted_node_counts

  ret.to_json
end