Sha256: da70ba25219d97d551d49ec3dade00b494dd547b8f74b5847a25914a2ad1b7dd

Contents?: true

Size: 710 Bytes

Versions: 4

Compression:

Stored size: 710 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)
      path = File.expand_path(path)
      dir = File.file?(path) ? File.dirname(path) : path
      File.basename(dir).delete('#').downcase
    end

    def split_prg_path(path)
      path = File.expand_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

4 entries across 4 versions & 1 rubygems

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