Sha256: 919a3b0a2d399b25382566361b80707300ce43164d69371ed11cc5e0e7c87378

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

class GhostWriter::DocumentIndex
  attr_reader :output, :documents

  def initialize(output, documents)
    extend(GhostWriter::Format::Markdown)
    @output = output
    @documents = documents
  end

  def write_file
    if GhostWriter.github_base_url
      base_url = GhostWriter.github_base_url + "/"
    else
      base_url = ""
    end

    document_list = documents.map do |document|
      list(
        link(document.description, base_url + "#{document.relative_path}")
      )
    end

    index_file = File.open(output, "w")
    index_file.write paragraph(<<EOP)
#{headword("API Examples")}
#{document_list.join("\n")}
EOP
    index_file.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ghost_writer-0.1.1 lib/ghost_writer/document_index.rb
ghost_writer-0.1.0 lib/ghost_writer/document_index.rb