Class: SyntaxTree::CLI::Json

Inherits:
Action
  • Object
show all
Defined in:
lib/syntax_tree/cli.rb

Overview

An action of the CLI that converts the source into its equivalent JSON representation.

Instance Method Summary collapse

Methods inherited from Action

#failure, #success

Instance Method Details

#run(handler, _filepath, source) ⇒ Object



122
123
124
125
# File 'lib/syntax_tree/cli.rb', line 122

def run(handler, _filepath, source)
  object = Visitor::JSONVisitor.new.visit(handler.parse(source))
  puts JSON.pretty_generate(object)
end