るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.015秒)

別のキーワード

  1. _builtin sub
  2. pathname sub
  3. string sub
  4. string sub!
  5. _builtin sub!

クラス

検索結果

Pathname#sub_ext(replace) -> Pathname (118003.0)

拡張子を与えられた文字列で置き換えた Pathname オブジェクトを返します。

...置き換えた Pathname オブジェクトを返します。

自身が拡張子を持たない場合は、与えられた文字列を拡張子として付加します。

@param replace 拡張子を文字列で指定します。

//emlist[例][ruby]{
require "pathname"

Pathname
('/usr/bin/shutdown...
...') # => #<Pathname:/usr/bin/shutdown.rb>
Pathname
('/home/user/test.txt').sub_ext('.pdf') # => #<Pathname:/home/user/test.pdf>
Pathname
('/home/user/test').sub_ext('.pdf') # => #<Pathname:/home/user/test.pdf>
Pathname
('/home/user/test.').sub_ext('.pdf') # => #<Pathname:/home/user/tes...
...t..pdf>
Pathname('/home/user/.test').sub_ext('.pdf') # => #<Pathname:/home/user/.test.pdf>
Pathname
('/home/user/test.tar.gz').sub_ext('.xz') # => #<Pathname:/home/user/test.tar.xz>
//}...