Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/judges/to_rel.rb
Overview
Adding method to_rel to all Ruby objects.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#to_rel ⇒ Object
Generates a relative name of a file (to the current dir).
Instance Method Details
#to_rel ⇒ Object
Generates a relative name of a file (to the current dir).
31 32 33 34 35 36 37 38 39 |
# File 'lib/judges/to_rel.rb', line 31 def to_rel s = File.absolute_path(to_s) p = Pathname.new(s).relative_path_from(Dir.getwd) if p.directory? "#{p}/" else p.to_s end end |