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.



27
28
29
30
31
32
33
34
35
36
# File 'lib/samovar/output/usage_formatter.rb', line 27

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)


19
20
21
22
23
24
25
# File 'lib/samovar/output/usage_formatter.rb', line 19

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

Instance Method Details



67
68
69
# File 'lib/samovar/output/usage_formatter.rb', line 67

def print
	map(@rows)
end