Sha256: c39b423e9bfed115ae6d8c0871c1d34101cc61a58600fe4065a5a79a88269f04

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require_relative "doc/format_code2doc"
require_relative "doc/format_concept2doc"
require_relative "doc/format_problem2doc"
require_relative "../version"

class Export2Doc
  def call(data, project)
    file_open(project)
    export_codes(data[:codes])
    export_concepts(data[:concepts])
    export_problems(data[:problems])
    @file.close
  end

  private

  def file_open(project)
    @file = File.new(project.get(:lessonpath), "w")
    @file.write("Asker    : version #{Asker::VERSION}\n")
    @file.write("Filename : #{project.get(:lessonname)}\n")
    @file.write("Datetime : #{Time.new}\n\n")
  end

  def export_codes(codes)
    codes.each do |code|
      @file.write(FormatCode2Doc.new.call(code)) if code.process
    end
  end

  def export_concepts(concepts)
    concepts.each do |concept|
      @file.write(FormatConcept2Doc.new.call(concept)) if concept.process
    end
  end

  def export_problems(problems)
    problems.each do |problem|
      @file.write(FormatProblem2Doc.new(problem).call) if problem.process
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
asker-tool-2.9.4 lib/asker/exporter/export2doc.rb
asker-tool-2.9.3 lib/asker/exporter/export2doc.rb
asker-tool-2.9.2 lib/asker/exporter/export2doc.rb
asker-tool-2.9.1 lib/asker/exporter/export2doc.rb
asker-tool-2.9.0 lib/asker/exporter/export2doc.rb