Class: Multipri::CliUI

Inherits:
Object
  • Object
show all
Defined in:
lib/multipri/cli_ui.rb

Class Method Summary collapse

Class Method Details

.read(args) ⇒ Object



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

def self.read(args)
  options = {}
  OptionParser.new do |opts|
    opts.on('-c', '--count [COUNT]', Integer, 'Number of primes to use') do |c|
      options[:count] = c
    end
  end.parse(args)
  options.fetch(:count)
end

.write(table) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/multipri/cli_ui.rb', line 16

def self.write(table)
  style = {
    all_separators: false
  }
  Terminal::Table.new(style: style) do |t|
    t.headings = ['', *table.row_titles]
    table.rows.each do |r|
      t << [r.title, *r.entries]
    end
  end
end