Class: SyntaxTree::CLI::Format

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

Overview

An action of the CLI that formats the input source and prints it out.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Action

#failure, #success

Constructor Details

#initialize(print_width:) ⇒ Format

Returns a new instance of Format.



169
170
171
# File 'lib/syntax_tree/cli.rb', line 169

def initialize(print_width:)
  @print_width = print_width
end

Instance Attribute Details

Returns the value of attribute print_width.



167
168
169
# File 'lib/syntax_tree/cli.rb', line 167

def print_width
  @print_width
end

Instance Method Details

#run(item) ⇒ Object



173
174
175
# File 'lib/syntax_tree/cli.rb', line 173

def run(item)
  puts item.handler.format(item.source, print_width)
end