検索結果
先頭5件
-
ARGF
. class # pos -> Integer (26227.0) -
ARGFが現在開いているファイルのファイルポインタの現在の位置をバイト単位 の整数で返します。
...ARGFが現在開いているファイルのファイルポインタの現在の位置をバイト単位
の整数で返します。
ARGF.pos # => 0
ARGF.gets # => "This is line one\n"
ARGF.pos # => 17
@see IO#pos, IO#tell, ARGF.class#pos=... -
IO
# pos -> Integer (26215.0) -
ファイルポインタの現在の位置を整数で返します。
...タの現在の位置を整数で返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "This is line one\n")
File.open("testfile") do |f|
f.pos # => 0
f.gets # => "This is line one\n"
f.pos # => 17
end
//}... -
Dir
# pos -> Integer (26209.0) -
ディレクトリストリームの現在の位置を整数で返します。
...ディレクトリストリームの現在の位置を整数で返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("/tmp") {|d|
d.each {|f|
p d.pos
}
}
//}... -
Array
# transpose -> Array (20202.0) -
自身を行列と見立てて、行列の転置(行と列の入れ換え)を行いま す。転置した配列を生成して返します。空の配列に対しては空の配列を生 成して返します。
...外
TypeError が発生します。各要素のサイズが不揃いな配列に対して
は、例外 IndexError が発生します。
//emlist[例][ruby]{
p [[1,2],
[3,4],
[5,6]].transpose
# => [[1, 3, 5], [2, 4, 6]]
p [].transpose
# => []
p [1,2,3].transpose
# => -:1:in `transpose': can......not convert Fixnum into Array (TypeError)
# from -:1
p [[1,2],
[3,4,5],
[6,7]].transpose
# => -:3:in `transpose': element size differ (3 should be 2) (IndexError)
//}... -
Float
# positive? -> bool (20202.0) -
self が 0 より大きい場合に true を返します。そうでない場合に false を返します。
...self が 0 より大きい場合に true を返します。そうでない場合に false を返します。
//emlist[例][ruby]{
0.1.positive? # => true
0.0.positive? # => false
-0.1.positive? # => false
//}
@see Float#negative?... -
Numeric
# positive? -> bool (20202.0) -
self が 0 より大きい場合に true を返します。そうでない場合に false を返します。
...self が 0 より大きい場合に true を返します。そうでない場合に false を返します。
//emlist[例][ruby]{
1.positive? # => true
0.positive? # => false
-1.positive? # => false
//}
@see Numeric#negative?... -
Rational
# positive? -> bool (20202.0) -
self が 0 より大きい場合に true を返します。そうでない場合に false を返します。
...self が 0 より大きい場合に true を返します。そうでない場合に false を返します。
//emlist[例][ruby]{
Rational(1, 2).positive? # => true
Rational(-1, 2).positive? # => false
//}
@see Rational#negative?... -
String
# insert(pos , other) -> self (14341.0) -
pos 番目の文字の直前に文字列 other を挿入します。 self[pos, 0] = other と同じ操作です。
...
pos 番目の文字の直前に文字列 other を挿入します。
self[pos, 0] = other と同じ操作です。
@param pos 文字列を挿入するインデックス
@param other 挿入する文字列
//emlist[例][ruby]{
str = "foobaz"
str.insert(3, "bar")
p str # => "foobarbaz"
//}......@see String#[]=... -
Dir
# seek(pos) -> self (14243.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
... pos に移動させます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read......# => "."
i = d.tell # => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
Array
# delete _ at(pos) -> object | nil (14241.0) -
指定された位置 pos にある要素を取り除きそれを返します。 pos が範囲外であったら nil を返します。
...指定された位置 pos にある要素を取り除きそれを返します。
pos が範囲外であったら nil を返します。
Array#at と同様に負のインデックスで末尾から位置を指定するこ
とができます。
@param pos 削除したい要素のインデックス......暗黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
array = [0, 1, 2, 3, 4]
array.delete_at 2
p array #=> [0, 1, 3, 4]
//}...