Class: AtCoderFriends::PathInfo
- Inherits:
-
Object
- Object
- AtCoderFriends::PathInfo
- Defined in:
- lib/at_coder_friends/path_info.rb
Overview
holds target path information
Constant Summary collapse
- SMP_DIR =
'data'
- CASES_DIR =
'cases'
- TMP_DIR =
'.tmp'
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #cases_dir ⇒ Object
- #cases_out_dir ⇒ Object
- #components ⇒ Object
- #contest_name ⇒ Object
-
#initialize(path) ⇒ PathInfo
constructor
A new instance of PathInfo.
- #smp_dir ⇒ Object
- #src_dir ⇒ Object
- #tmp_dir ⇒ Object
Constructor Details
#initialize(path) ⇒ PathInfo
Returns a new instance of PathInfo.
12 13 14 15 16 17 |
# File 'lib/at_coder_friends/path_info.rb', line 12 def initialize(path) @path = path # in setup command, path is directory name (existent/non-existent) # in other commands(test, submit, verify), path is existent file name @dir = File.file?(path) ? File.dirname(path) : path end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
10 11 12 |
# File 'lib/at_coder_friends/path_info.rb', line 10 def dir @dir end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/at_coder_friends/path_info.rb', line 10 def path @path end |
Instance Method Details
#cases_dir ⇒ Object
39 40 41 |
# File 'lib/at_coder_friends/path_info.rb', line 39 def cases_dir File.join(dir, CASES_DIR) end |
#cases_out_dir ⇒ Object
43 44 45 |
# File 'lib/at_coder_friends/path_info.rb', line 43 def cases_out_dir File.join(dir, TMP_DIR, CASES_DIR) end |
#components ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/at_coder_friends/path_info.rb', line 23 def components # overwrites @dir here for non-existent files (test purpose) @dir, prg = File.split(path) base, ext = prg.split('.') q = base.gsub(/_[^#_]+\z/, '') [path, dir, prg, base, ext, q] end |
#contest_name ⇒ Object
19 20 21 |
# File 'lib/at_coder_friends/path_info.rb', line 19 def contest_name File.basename(dir).delete('#').downcase end |
#smp_dir ⇒ Object
35 36 37 |
# File 'lib/at_coder_friends/path_info.rb', line 35 def smp_dir File.join(dir, SMP_DIR) end |
#src_dir ⇒ Object
31 32 33 |
# File 'lib/at_coder_friends/path_info.rb', line 31 def src_dir dir end |
#tmp_dir ⇒ Object
47 48 49 |
# File 'lib/at_coder_friends/path_info.rb', line 47 def tmp_dir File.join(dir, TMP_DIR) end |