Class: Pathname
- Extended by:
- Gorillib::Pathref
- Defined in:
- lib/gorillib/pathname.rb,
lib/gorillib/pathname/utils.rb
Constant Summary
Constants included from Gorillib::Pathref
Class Method Summary collapse
Instance Method Summary collapse
-
#corename ⇒ Object
The basename without extension (using self.extname as the extension).
-
#exists?(*args) ⇒ Boolean
same as
#exist?
. -
#find_all ⇒ Object
Like find, but returns an enumerable.
-
#if_missing(options = {}, &block) ⇒ Object
Executes the block (passing the opened file) if the file does not exist.
-
#inspect_compact ⇒ String
Compact string rendering.
- #mkparent ⇒ Object
Methods included from Gorillib::Pathref
of, register_default_paths, register_path, register_paths, relpath_to, unregister_path
Class Method Details
.receive(obj) ⇒ Object
89 90 91 92 |
# File 'lib/gorillib/pathname.rb', line 89 def self.receive(obj) return obj if obj.nil? obj.is_a?(self) ? obj : new(obj) end |
Instance Method Details
#corename ⇒ Object
Returns the basename without extension (using self.extname as the extension).
95 96 97 |
# File 'lib/gorillib/pathname.rb', line 95 def corename basename(self.extname) end |
#exists?(*args) ⇒ Boolean
same as #exist?
3 |
# File 'lib/gorillib/pathname/utils.rb', line 3 def exists?(*args) exist?(*args) ; end |
#find_all ⇒ Object
Like find, but returns an enumerable
19 20 21 |
# File 'lib/gorillib/pathname/utils.rb', line 19 def find_all Enumerator.new{|yielder| find{|path| yielder << path } } end |
#if_missing(options = {}, &block) ⇒ Object
Executes the block (passing the opened file) if the file does not exist. Ignores the block otherwise. The block is required.
31 32 33 34 35 36 37 38 |
# File 'lib/gorillib/pathname/utils.rb', line 31 def if_missing(={}, &block) ArgumentError.block_required!(block) return self if exist? && (not [:force]) # mkparent open(([:mode] || 'w'), &block) return self end |
#inspect_compact ⇒ String
Returns compact string rendering.
100 |
# File 'lib/gorillib/pathname.rb', line 100 def inspect_compact() to_path.dump ; end |
#mkparent ⇒ Object
12 13 14 15 |
# File 'lib/gorillib/pathname/utils.rb', line 12 def mkparent dirname.mkpath return self end |