Class: Samovar::Output::UsageFormatter

Inherits:
Mapping::Model
  • Object
show all
Defined in:
lib/samovar/output/usage_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rows, output) ⇒ UsageFormatter

Returns a new instance of UsageFormatter.



42
43
44
45
46
47
48
49
50
51
# File 'lib/samovar/output/usage_formatter.rb', line 42

def initialize(rows, output)
	@rows = rows
	@output = output
	@width = 80
	
	@terminal = Console::Terminal.for(@output)
	@terminal[:header] = @terminal.style(nil, nil, :bright)
	@terminal[:description] = @terminal.style(:blue)
	@terminal[:error] = @terminal.style(:red)
end

Class Method Details

Yields:

  • (formatter)


34
35
36
37
38
39
40
# File 'lib/samovar/output/usage_formatter.rb', line 34

def self.print(rows, output)
	formatter = self.new(rows, output)
	
	yield formatter if block_given?
	
	formatter.print
end

Instance Method Details



82
83
84
# File 'lib/samovar/output/usage_formatter.rb', line 82

def print
	map(@rows)
end