class FeduxOrgStdlib::List

A list

@example Usage

data = [
  {
    item1: 'data1',
    item2: 'data2'
  },
  {
    item1: 'data1',
    item2: 'data2'
  },
]

list = List.new(data)
puts list

Attributes

data[R]

Public Class Methods

new(*data) click to toggle source
# File lib/fedux_org_stdlib/list.rb, line 31
def initialize(*data)
  @data = data.flatten.map { |e| Hash(e) }
end

Public Instance Methods

to_a() click to toggle source

Data as array

@return [Array]

The data as array
# File lib/fedux_org_stdlib/list.rb, line 47
def to_a
  Array(data)
end
to_s(**options) click to toggle source

Render data to table

@param [Hash] options

Options which are supported by Hirb
# File lib/fedux_org_stdlib/list.rb, line 39
def to_s(**options)
  Hirb::Helpers::Table.render data, header_filter: proc(&:humanize), **options
end