lib/pa.rb in pa-1.3.2 vs lib/pa.rb in pa-1.3.3
- old
+ new
@@ -169,11 +169,22 @@
# -> ".ogg", ""
def ext2(path)
File.extname(get(path))
end
+
+ # Return path without ext.
+ #
+ # Pa.head2("/foo/a.txt") -> "/foo/a")
+ #
+ def head2(path)
+ p = get(path)
+ ext = File.extname(p)
+ ext.empty? ? p : p[0...-ext.length]
+ end
+
# => "ogg", ""
def fext2(path)
File.extname(get(path)).gsub(/^\./, "")
end
@@ -249,18 +260,18 @@
Pa(obj)
end
end
end
- DELEGATE_ATTR_METHODS2 = [ :dir2, :dir_strict2, :base2, :name2, :ext2, :fext2]
+ DELEGATE_ATTR_METHODS2 = [ :dir2, :dir_strict2, :base2, :name2, :ext2, :fext2, :head2]
DELEGATE_ATTR_METHODS = [ :absolute, :dir, :dir_strict, :rel, :rea ]
DELEGATE_METHODS2 = [ :join2 ]
DELEGATE_METHODS = [ :change, :join]
DELEGATE_TO_PATH2 = [ :sub2, :gsub2 ]
DELEGATE_TO_PATH = [:match, :start_with?, :end_with?]
attr_reader :path2
- attr_reader :absolute2, :dir2, :dir_strict2, :base2, :name2, :short2, :ext2, :fext2, :rel2, :rea2
+ attr_reader :absolute2, :dir2, :dir_strict2, :base2, :name2, :short2, :ext2, :fext2, :head2, :rel2, :rea2
attr_reader :options
# @param [Hash] o option
# @option o [String] rel relative path
# @option o [String] base_dir