aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/models/active_storage
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2017-08-20 16:30:15 -0400
committerGeorge Claghorn <george.claghorn@gmail.com>2017-08-20 16:30:15 -0400
commit8bd14971b908b7d3c7b41a715d2904df88ee7b3c (patch)
treeba0ef905ea034c3074073ca371d8a0d9a9650bab /activestorage/app/models/active_storage
parent81ca1556b6181fb62a3d6b9f0c14fb38f6fd1b57 (diff)
downloadrails-8bd14971b908b7d3c7b41a715d2904df88ee7b3c.tar.gz
rails-8bd14971b908b7d3c7b41a715d2904df88ee7b3c.tar.bz2
rails-8bd14971b908b7d3c7b41a715d2904df88ee7b3c.zip
Rename ActiveStorage::Filename#extname to extension_with_delimiter
Diffstat (limited to 'activestorage/app/models/active_storage')
-rw-r--r--activestorage/app/models/active_storage/filename.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/activestorage/app/models/active_storage/filename.rb b/activestorage/app/models/active_storage/filename.rb
index 6a9889addf..df21078718 100644
--- a/activestorage/app/models/active_storage/filename.rb
+++ b/activestorage/app/models/active_storage/filename.rb
@@ -9,21 +9,23 @@ class ActiveStorage::Filename
@filename = filename
end
- # Filename.new("racecar.jpg").extname # => ".jpg"
- def extname
- File.extname(@filename)
+ # Filename.new("racecar.jpg").base # => "racecar"
+ def base
+ File.basename @filename, extension_with_delimiter
end
- # Filename.new("racecar.jpg").extension # => "jpg"
- def extension
- extname.from(1)
+ # Filename.new("racecar.jpg").extension_with_delimiter # => ".jpg"
+ def extension_with_delimiter
+ File.extname @filename
end
- # Filename.new("racecar.jpg").base # => "racecar"
- def base
- File.basename(@filename, extname)
+ # Filename.new("racecar.jpg").extension_without_delimiter # => "jpg"
+ def extension_without_delimiter
+ extension_with_delimiter.from(1).to_s
end
+ alias_method :extension, :extension_without_delimiter
+
# Filename.new("foo:bar.jpg").sanitized # => "foo-bar.jpg"
# Filename.new("foo/bar.jpg").sanitized # => "foo-bar.jpg"
#