Sha256: c809a1fa6b7ba4beee2d8a0d6d19b02360a9e366dc74b1ad5475b1812631b8bd

Contents?: true

Size: 673 Bytes

Versions: 5

Compression:

Stored size: 673 Bytes

Contents

require_relative "question_gift_formatter"

class ExportProblem2Gift
  ##
  # Export an Array of problems to gift format file
  # @param problems (Array)
  def call(problems, file)
    problems.each { |problem| export_one(problem, file) }
  end

  private

  def export_one(problem, file)
    return false unless problem.process?

    file.write head(problem)
    problem.questions.each do |question|
      file.write QuestionGiftFormatter.to_s(question)
    end
    true
  end

  def head(problem)
    s = "\n"
    s += "// " + "=" * 50 + "\n"
    s += "// Problem: #{problem.name} (#{problem.questions.size} questions)\n"
    s += "// " + "=" * 50 + "\n"
    s
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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