るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < ... 16 17 18 19 20 ... > >>

String#hex -> Integer (3114.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...

//emlist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10".hex # => -16

p "xyz".hex # => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

@see String#oct, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float

このメ...
...ソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer#to_s
などを使ってください。...

String#include?(substr) -> bool (3114.0)

文字列中に部分文字列 substr が含まれていれば真を返します。

...文字列中に部分文字列 substr が含まれていれば真を返します。

@param substr 検索する文字列

//emlist[例][ruby]{
"hello".include? "lo" #=> true
"hello".include? "ol" #=> false
"hello".include? ?h #=> true
//}...

String#index(pattern, pos = 0) -> Integer | nil (3114.0)

文字列のインデックス pos から右に向かって pattern を検索し、 最初に見つかった部分文字列の左端のインデックスを返します。 見つからなければ nil を返します。

...文字列のインデックス pos から右に向かって pattern を検索し、
最初に見つかった部分文字列の左端のインデックスを返します。
見つからなければ nil を返します。

引数 pattern は探索する部分文字列または正規表現で指定し...
...@param pattern 探索する部分文字列または正規表現
@param pos 探索を開始するインデックス

//emlist[例][ruby]{
p "astrochemistry".index("str") # => 1
p "regexpindex".index(/e.*x/, 2) # => 3
p "character".index(?c) # => 0

p "foobarfo...
...obar".index("bar", 6) # => 9
p "foobarfoobar".index("bar", -6) # => 9
//}

@see String#rindex...
...obar".index("bar", 6) # => 9
p "foobarfoobar".index("bar", -6) # => 9
//}

@see String#rindex
@see String#byteindex...

String#length -> Integer (3114.0)

文字列の文字数を返します。バイト数を知りたいときは bytesize メソッドを使ってください。

...いときは bytesize メソッドを使ってください。

//emlist[例][ruby]{
"test".length # => 4
"test".size # => 4
"テスト".length # => 3
"テスト".size # => 3
"\x80\u3042".length # => 2
"\x80\u3042".size # => 2
//}

@see String#bytesize...

String#ljust(width, padding = &#39; &#39;) -> String (3114.0)

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

...たときは
空白文字の代わりに padding を詰めます。

@param width 返り値の文字列の最小の長さ
@param padding 長さが width になるまで self の右側に詰める文字

//emlist[例][ruby]{
p "foo".ljust(10) # => "foo "
p "foo".ljust(9)...
...# => "foo "
p "foo".ljust(8) # => "foo "
p "foo".ljust(2) # => "foo"
p "foo".ljust(1) # => "foo"
p "foo".ljust(10, "*") # => "foo*******"
//}

@see String#center, String#rjust...

絞り込み条件を変える

String#next! -> String (3114.0)

self を「次の」文字列に置き換えます。 「次の」文字列は、アルファベットなら 16 進数、 数字なら 10 進数とみなして計算されます。 「次の」文字列の計算では "99" → "100" のように繰り上げも行われます。 このとき負符号などは考慮されません。

...
単に文字列をバイト列として扱います。

なお、succ! と逆の動作をするメソッドはありません。

//emlist[例][ruby]{
p "aa".succ # => "ab"

# 繰り上がり
p "99".succ # => "100"
p "a9".succ # => "b0"
p "Az".succ # => "Ba"
p "zz".succ # => "aaa"
p "-...
...# => "-10"
p "9".succ # => "10"
p "09".succ # => "10"

# アルファベット・数字とそれ以外の混在
p "1.9.9".succ # => # "2.0.0"

# アルファベット・数字以外のみ
p ".".succ # => "/"
p "\0".succ # => "\001"
p "\377".succ # => "\001\000"
//}

@see String#succ...

String#setbyte(index, b) -> Integer (3114.0)

index バイト目のバイトを b に変更します。

...セットした値を返します。

@param index バイトをセットする位置
@param b セットするバイト(0 から 255 までの整数)
@raise IndexError 範囲外に値をセットしようとした場合に発生します。

//emlist[例][ruby]{
s = "Sunday"
s.setbyte(0, 77)
s.setbyt...

String#size -> Integer (3114.0)

文字列の文字数を返します。バイト数を知りたいときは bytesize メソッドを使ってください。

...いときは bytesize メソッドを使ってください。

//emlist[例][ruby]{
"test".length # => 4
"test".size # => 4
"テスト".length # => 3
"テスト".size # => 3
"\x80\u3042".length # => 2
"\x80\u3042".size # => 2
//}

@see String#bytesize...

String#squeeze!(*chars) -> self | nil (3114.0)

chars に含まれる文字が複数並んでいたら 1 文字にまとめます。

...chars に含まれる文字が複数並んでいたら 1 文字にまとめます。

chars の形式は tr(1) と同じです。つまり、
`a-c' は a から c を意味し、"^0-9" のように
文字列の先頭が `^' の場合は指定文字以外を意味します。

`-' は文字列の両...
...を返します。

@param chars 1文字にまとめる文字。

//emlist[例][ruby]{
str = "112233445566778899"
str.squeeze!
p str # =>"123456789"

str = "112233445566778899"
str.squeeze!("2-8")
p str # =>"11234567899"

str = "123456789"
str.squeeze! # => nil
p str # =>"123456789"...
<< < ... 16 17 18 19 20 ... > >>