るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< < ... 5 6 7 8 9 ... > >>

String#to_r -> Rational (15120.0)

自身を有理数(Rational)に変換した結果を返します。

...自身を有理数(Rational)に変換した結果を返します。

Kernel.#Rational に文字列を指定した時のように、以下のいずれかの形
式で指定します。

* "1/3" のような分数の形式
* "0.3" のような10進数の形式
* "0.3E0" のような x.xEn の形...
...スコアで繋いだ形式

//emlist[例][ruby]{
' 2 '.to_r # => (2/1)
'1/3'.to_r # => (1/3)
'-9.2'.to_r # => (-46/5)
'-9.2E2'.to_r # => (-920/1)
'1_234_567'.to_r # => (1234567/1)
'1_234/5_678'.to_r # => (617/2839)
//}

Kernel.#Rational に文字列を指定した時...
...//emlist[][ruby]{
'21 june 09'.to_r # => (21/1)
'21/06/09'.to_r # => (7/2) # 21/6 を約分して 7/2。
//}

変換できないような文字列を指定した場合は 0/1 を返します。

//emlist[][ruby]{
'foo'.to_r # => (0/1)
''.to_r # => (0/1)
'bwv 1079'.to_r #...

String#concat(other) -> self (15115.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...other を破壊的に連結します。
other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

self を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p str # => "str...
...ingXXX"

str << "YYY"
p str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p str # => "stringXXXYYYA"
//}...

String#delete!(*strs) -> self | nil (15114.0)

self から strs に含まれる文字を破壊的に取り除きます。

...self から strs に含まれる文字を破壊的に取り除きます。

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

「-」は文字列の両端...
...れます。

@return 通常は self を返しますが、何も変更が起こらなかった場合は nil を返します。

@param strs 削除する文字列を示す文字列 (のリスト)

//emlist[例][ruby]{
str = "123456789"
p str.delete!("2378") #=> "14569"
p str...
...#=> "14569"

str = "123456789"
p str.delete!("2-8", "^4-6") #=> "14569"
p str #=> "14569"

str = "abc"
p str.delete!("2378") #=> "nil"
p str #=> "abc"
//}

@see String#delete...

String#each_byte -> Enumerator (15114.0)

文字列の各バイトに対して繰り返します。

...文字列の各バイトに対して繰り返します。

//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114

"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}

@see String#bytes...

String#each_codepoint -> Enumerator (15114.0)

文字列の各コードポイントに対して繰り返します。

...ントに対して繰り返します。

UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 124...
...31, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

絞り込み条件を変える

String#each_codepoint {|codepoint| block } -> self (15114.0)

文字列の各コードポイントに対して繰り返します。

...ントに対して繰り返します。

UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 124...
...31, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

String#insert(pos, other) -> self (15114.0)

pos 番目の文字の直前に文字列 other を挿入します。 self[pos, 0] = other と同じ操作です。

...の直前に文字列 other を挿入します。
self[pos, 0] = other と同じ操作です。

@param pos 文字列を挿入するインデックス
@param other 挿入する文字列

//emlist[例][ruby]{
str = "foobaz"
str.insert(3, "bar")
p str # => "foobarbaz"
//}

@see String#[]=...

String#length -> Integer (15114.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#concat(*arguments) -> self (15110.0)

self に複数の文字列を破壊的に連結します。

...は Integer#chr の結果に相当する文字を末尾に追加します。追加する文字のエンコーディングは self.encoding です。

self を返します。

@param arguments 複数の文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "foo"
str.concat
p str # =>...
..."foo"

str = "foo"
str.concat "bar", "baz"
p str # => "foobarbaz"

str = "foo"
str.concat("!", 33, 33)
p str # => "foo!!!"
//}...

String#count(*chars) -> Integer (15108.0)

chars で指定された文字が文字列 self にいくつあるか数えます。

...chars で指定された文字が文字列 self にいくつあるか数えます。

検索する文字を示す引数 chars の形式は tr(1) と同じです。
つまり、「"a-c"」は文字 a から c を意味し、
「"^0-9"」のように文字列の先頭が「^」の場合は
指定文...
...を数える文字のパターン

//emlist[例][ruby]{
p 'abcdefg'.count('c') # => 1
p '123456789'.count('2378') # => 4
p '123456789'.count('2-8', '^4-6') # => 4

# ファイルの行数を数える
n_lines = File.read("foo").count("\n")

# ファイルの末尾に改行コ...
...ードがない場合にも対処する
buf = File.read("foo")
n_lines = buf.count("\n")
n_lines += 1 if /[^\n]\z/ =~ buf
# if /\n\z/ !~ buf だと空ファイルを 1 行として数えてしまうのでダメ
//}...

絞り込み条件を変える

<< < ... 5 6 7 8 9 ... > >>