Sha256: 82527c5ce255310952bffba26bdebb6b3843382317959c0943ab361ccb6e093e

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

# frozen_string_literal: true

require_relative './template'
require_relative './helpers'
require_relative './content_shaper'

class Tabled
  DEFAULT_OPTIONS = { framed: true, row_separator: '-', titles: [] }.freeze
  attr_accessor :data, :columns_width, :content, :options

  def initialize(data, **options)
    @options = DEFAULT_OPTIONS.merge(options)
    @data = Tabled::Helpers.convert_to_required_structure(data)
    @columns_width = Tabled::Helpers.calculate_columns_width(data: data, options: @options)
    @content = Tabled::ContentShaper.new(data, @columns_width, @options).shape
  end

  def print_to_console
    print content.join("\n")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabled-0.0.5 lib/tabled.rb