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 Attribute Summary

Attributes inherited from Action

#options

Instance Method Summary collapse

Methods inherited from Action

#failure, #initialize, #success

Constructor Details

This class inherits a constructor from SyntaxTree::CLI::Action

Instance Method Details

#run(item) ⇒ Object



327
328
329
330
# File 'lib/syntax_tree/cli.rb', line 327

def run(item)
  object = item.handler.parse(item.source).accept(JSONVisitor.new)
  puts JSON.pretty_generate(object)
end