Sha256: 148142ce9df4d5c9159c548f1c02b7605f7bddcb6ab8ac624b2f3214a6e73621

Contents?: true

Size: 1005 Bytes

Versions: 5

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true

module AtCoderFriends
  DataSample = Struct.new(:no, :ext, :txt) do
    def initialize(no, ext, txt)
      no = no.tr('0-9', '0-9').to_i
      txt = txt.lstrip.gsub("\r\n", "\n")
      super(no, ext, txt)
    end
  end

  InputDef = Struct.new(:container, :item, :names, :size) do
    def initialize(container, item, names, size = [])
      super(container, item, names, size)
    end
  end

  SourceSample = Struct.new(:ext, :txt)

  # holds problem information
  class Problem
    attr_reader :q, :fmt, :smps, :srcs
    attr_accessor :html, :desc, :defs

    def initialize(q)
      @q = q
      @html = ''
      @desc = ''
      @fmt = ''
      @smps = []
      @defs = []
      @srcs = []
      yield self if block_given?
    end

    def fmt=(f)
      @fmt = f.lstrip.gsub("\r\n", "\n")
    end

    def add_smp(no, ext, txt)
      @smps << DataSample.new(no, ext, txt)
    end

    def add_src(ext, txt)
      @srcs << SourceSample.new(ext, txt)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
at_coder_friends-0.5.0 lib/at_coder_friends/problem.rb
at_coder_friends-0.4.0 lib/at_coder_friends/problem.rb
at_coder_friends-0.3.3 lib/at_coder_friends/problem.rb
at_coder_friends-0.3.2 lib/at_coder_friends/problem.rb
at_coder_friends-0.3.1 lib/at_coder_friends/problem.rb