Sha256: 17f53a229a898360e7b25b1454c69fd58b35c31e8783a54a0378be24aab1ac82
Contents?: true
Size: 739 Bytes
Versions: 56
Compression:
Stored size: 739 Bytes
Contents
module GLI module Commands module HelpModules # Given a list of two-element lists, formats on the terminal class ListFormatter def initialize(list,wrapper_class=TextWrapper) @list = list @wrapper_class = wrapper_class end # Output the list to the output_device def output(output_device) return if @list.empty? max_width = @list.map { |_| _[0].length }.max wrapper = @wrapper_class.new(Terminal.instance.size[0],4 + max_width + 3) @list.each do |(name,description)| output_device.printf(" %-#{max_width}s - %s\n",name,wrapper.wrap(String(description).strip)) end end end end end end
Version data entries
56 entries across 56 versions & 2 rubygems