Sha256: d891dd5c41228a16980380600109977cfedba8c90ea8c3eee7c04c0937e93ebb

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

module AtCoderFriends
  # Common methods and behaviors for dealing with paths.
  module PathUtil
    module_function

    SMP_DIR = 'data'
    CASES_DIR = 'cases'

    def contest_name(path)
      dir = File.file?(path) ? File.dirname(path) : path
      File.basename(dir).delete('#').downcase
    end

    def split_prg_path(path)
      dir, prg = File.split(path)
      base, ext = prg.split('.')
      q = base.split('_')[0]
      [path, dir, prg, base, ext, q]
    end

    def smp_dir(dir)
      File.join(dir, SMP_DIR)
    end

    def cases_dir(dir)
      File.join(dir, CASES_DIR)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
at_coder_friends-0.5.0 lib/at_coder_friends/path_util.rb