Class: Seafoam::Formatters::Json::SourceFormatter

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

Overview

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

Instance Attribute Summary

Attributes inherited from Base::SourceFormatter

#source_position

Instance Method Summary collapse

Methods inherited from Base::SourceFormatter

#initialize

Constructor Details

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

Instance Method Details

#formatObject



70
71
72
# File 'lib/seafoam/formatters/json.rb', line 70

def format
  Seafoam::Graal::Source.walk(source_position, &method(:render_method)).to_json
end

#render_method(method) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/seafoam/formatters/json.rb', line 74

def render_method(method)
  declaring_class = method[:declaring_class]
  name = method[:method_name]
  {
    class: declaring_class,
    method: name,
  }
end