るりまサーチ

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

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. integer >
  4. complex >
  5. module >

ライブラリ

クラス

検索結果

String#center(width, padding = ' ') -> String (24350.0)

長さ width の文字列に self を中央寄せした文字列を返します。 self の長さが width より長い時には元の文字列の複製を返します。 また、第 2 引数 padding を指定したときは 空白文字の代わりに padding を詰めます。

...o".center(10) # => " foo "
p "foo".center(9) # => " foo "
p "foo".center(8) # => " foo "
p "foo".center(7) # => " foo "
p "foo".center(3) # => "foo"
p "foo".center(2) # => "foo"
p "foo".center(1) # => "foo"
p "foo".center(10, "*") # => "...