Class: File
Class Method Summary collapse
- .expand_local_path(*args, &blk) ⇒ Object
- .if_readable(path, &blk) ⇒ Object
- .if_writable(path, &blk) ⇒ Object
Class Method Details
.expand_local_path(*args, &blk) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/lab42/core/file.rb', line 4 def *args, &blk raise ArgumentError, 'need a block to determine source location' unless blk values = args + Array( blk.() ) File.join( '..', values.compact), blk.source_location.first end |
.if_readable(path, &blk) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lab42/core/file.rb', line 11 def if_readable path, &blk return Lab42::File.enumerate_on_file_readable path unless blk return unless readable? path return blk.() if blk.arity.zero? File.open path, &blk end |
.if_writable(path, &blk) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/lab42/core/file.rb', line 21 def if_writable path, &blk return Lab42::File.enumerate_on_file_writable path unless blk return unless writable? path return blk.() if blk.arity.zero? File.open path, "a", &blk end |