aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/models/active_storage/filename.rb
diff options
context:
space:
mode:
authorYoshiyuki Hirano <yhirano@me.com>2017-08-30 02:40:03 +0900
committerYoshiyuki Hirano <yhirano@me.com>2017-08-30 02:40:03 +0900
commite38900b8453e8709943850b4651e1a1929c40967 (patch)
tree6565adf0db5b1eaedcf2a06728d096d067a50fae /activestorage/app/models/active_storage/filename.rb
parent9a66a22102db76896f400939165ec92280e092e7 (diff)
downloadrails-e38900b8453e8709943850b4651e1a1929c40967.tar.gz
rails-e38900b8453e8709943850b4651e1a1929c40967.tar.bz2
rails-e38900b8453e8709943850b4651e1a1929c40967.zip
Update Active Storage docs [ci skip]
Diffstat (limited to 'activestorage/app/models/active_storage/filename.rb')
-rw-r--r--activestorage/app/models/active_storage/filename.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/activestorage/app/models/active_storage/filename.rb b/activestorage/app/models/active_storage/filename.rb
index 10b1116d52..dead6b6d33 100644
--- a/activestorage/app/models/active_storage/filename.rb
+++ b/activestorage/app/models/active_storage/filename.rb
@@ -9,25 +9,33 @@ class ActiveStorage::Filename
@filename = filename
end
- # Filename.new("racecar.jpg").base # => "racecar"
+ # Returns the basename of the filename.
+ #
+ # ActiveStorage::Filename.new("racecar.jpg").base # => "racecar"
def base
File.basename @filename, extension_with_delimiter
end
- # Filename.new("racecar.jpg").extension_with_delimiter # => ".jpg"
+ # Returns the extension with delimiter of the filename.
+ #
+ # ActiveStorage::Filename.new("racecar.jpg").extension_with_delimiter # => ".jpg"
def extension_with_delimiter
File.extname @filename
end
- # Filename.new("racecar.jpg").extension_without_delimiter # => "jpg"
+ # Returns the extension without delimiter of the filename.
+ #
+ # ActiveStorage::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"
+ # Returns the sanitized filename.
+ #
+ # ActiveStorage::Filename.new("foo:bar.jpg").sanitized # => "foo-bar.jpg"
+ # ActiveStorage::Filename.new("foo/bar.jpg").sanitized # => "foo-bar.jpg"
#
# ...and any other character unsafe for URLs or storage is converted or stripped.
def sanitized