Class: TWKB::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/twkb/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Formatter

Returns a new instance of Formatter.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
# File 'lib/twkb/formatter.rb', line 6

def initialize(options)
  raise ArgumentError, 'Missing :stages argument' unless options[:stages]
  raise ArgumentError, ':stages is not a Hash' unless options[:stages].is_a? Hash
  @cell_width   = options[:cell_width]
  @cell_width ||= 15
  @stages = options[:stages]
  @title  = options[:title]
  prepare
end

Instance Method Details

#tableObject



16
17
18
19
# File 'lib/twkb/formatter.rb', line 16

def table
  stage_labels = @stages.keys.map{|k,v| @stages[k][:label]}
  Terminal::Table.new :title => @title, :headings => stage_labels, :rows => [@lanes]
end