Class: File
- Defined in:
- lib/backports/1.9.1/file/size.rb,
lib/backports/1.9.1/file/binary.rb,
lib/backports/3.1.0/file/dirname.rb
Defined Under Namespace
Modules: Constants
Class Method Summary collapse
- .dirname_with_depth(path, depth = 1) ⇒ Object
- .expand_path_with_potential_to_path(file, dir = nil) ⇒ Object
Instance Method Summary collapse
Class Method Details
.dirname_with_depth(path, depth = 1) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/backports/3.1.0/file/dirname.rb', line 5 def self.dirname_with_depth(path, depth = 1) return dirname_without_depth(path) if depth == 1 raise ArgumentError, "negative depth #{depth}" if depth < 0 depth.times { path = dirname_without_depth(path) } path end |
.expand_path_with_potential_to_path(file, dir = nil) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/backports/1.9.1/file/expand_path.rb', line 5 def (file, dir = nil) raise ArgumentError, 'home not set' if file == '~' && ENV["HOME"] == '' ( Backports.convert_path(file), dir == nil ? dir : Backports.convert_path(dir) ) end |
Instance Method Details
#size ⇒ Object
3 4 5 |
# File 'lib/backports/1.9.1/file/size.rb', line 3 def size stat.size end |