Sha256: 3e3c6b65142015a879c2282ac97e0cf9bc23389e580e276012a90aa0bbeb1a89

Contents?: true

Size: 712 Bytes

Versions: 4

Compression:

Stored size: 712 Bytes

Contents

# frozen_string_literal: false

require "rainbow"
require "terminal-table"

module ConceptDocFormatter
  ##
  # Formatter Concept into Doc
  # @param concept (Concept)
  def self.to_s(concept)
    out = ""
    out << "\n#{Rainbow(concept.name).bg(:blue).bright}\n\n"
    concept.texts.each { |i| out << "* #{i}\n" }
    out << "\n"
    concept.tables.each do |table|
      out << table_to_s(table)
    end
    out
  end

  ##
  # Formatter Table to Doc
  # @param table (Table)
  # @return String
  def self.table_to_s(table)
    my_screen_table = Terminal::Table.new do |st|
      st << table.fields
      st << :separator
      table.rows.each { |r| st.add_row r }
    end
    "#{my_screen_table}\n"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asker-tool-2.8.0 lib/asker/formatter/concept_doc_formatter.rb
asker-tool-2.7.2 lib/asker/formatter/concept_doc_formatter.rb
asker-tool-2.7.1 lib/asker/formatter/concept_doc_formatter.rb
asker-tool-2.7.0 lib/asker/formatter/concept_doc_formatter.rb