Sha256: e89dd7f815fcf4c423b4d2c49e42d035210fe9b3e7be7eb4f2f8d5d0d949cc63
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
# encoding: utf-8 require 'fedux_org_stdlib/require_files' require_library %w( hirb ) #require_library %w( tty ) module FeduxOrgStdlib # A list # # @example Usage # # data = [ # { # item1: 'data1', # item2: 'data2' # }, # { # item1: 'data1', # item2: 'data2' # }, # ] # # list = List.new(data) # puts list class List private attr_reader :data public def initialize(*data) @data = data.flatten.map { |e| Hash(e) } end # Render data to table # # @param [Hash] options # Options which are supported by Hirb def to_s(max_width: ENV['COLUMNS'].to_i, **options) Hirb::Helpers::Table.render data, header_filter: proc(&:humanize), max_width: max_width, **options end # Data as array # # @return [Array] # The data as array def to_a Array(data) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fedux_org-stdlib-0.8.5 | lib/fedux_org_stdlib/list.rb |
fedux_org-stdlib-0.8.4 | lib/fedux_org_stdlib/list.rb |