クラス
-
ARGF
. class (11) - Array (82)
- Binding (6)
- Encoding (11)
-
Enumerator
:: Lazy (22) - Exception (11)
- File (11)
- Float (11)
- IO (11)
- Integer (11)
- Method (11)
- Module (14)
- Numeric (11)
- Object (11)
- Proc (11)
- Rational (11)
- String (19)
- Thread (22)
-
Thread
:: Backtrace :: Location (77) - UnboundMethod (11)
モジュール
- Comparable (11)
- Enumerable (188)
- Warning (3)
キーワード
-
absolute
_ path (11) - all? (27)
- any? (42)
-
backtrace
_ locations (33) -
base
_ label (11) - between? (11)
-
close
_ on _ exec= (11) - collect (22)
-
collect
_ concat (33) - concat (38)
-
const
_ source _ location (5) -
deprecate
_ constant (9) -
flat
_ map (33) -
inplace
_ mode (11) - inspect (11)
-
instance
_ variable _ defined? (11) - label (11)
- lineno (11)
- map (22)
- none? (47)
- one? (47)
- path (11)
- replicate (11)
-
source
_ location (39) -
to
_ s (11) - truncate (55)
- warn (3)
検索結果
先頭5件
- Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] - Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil - Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil - Integer
# truncate(ndigits = 0) -> Integer | Float - Integer
# truncate(ndigits = 0) -> Integer
-
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (12303.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...on#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if Date.n......0, month, -1).day == 31
raise "#{month} is not long month"
end
def get_exception
return begin
yield
rescue => e
e
end
end
e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get......_exception'", "test.rb:15:in `<main>'"]
//}
@see Exception#backtrace... -
Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil (12303.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...スを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレーム......ange 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrace_locati......ons # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace::Location... -
Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil (12303.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...スを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレーム......ange 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrace_locati......ons # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace::Location... -
Integer
# truncate(ndigits = 0) -> Integer | Float (12215.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
...。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返......します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1.0
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}
@see Numeric#truncate... -
Integer
# truncate(ndigits = 0) -> Integer (12209.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
...aram ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-......1) # => 10
(-18).truncate(-1) # => -10
//}
@see Numeric#truncate... -
Array
# concat(*other _ arrays) -> self (12203.0) -
other_arrays の要素を自身の末尾に破壊的に連結します。
...][ruby]{
[ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
[ "a" ].concat( ["b"], ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
[ "a" ].concat #=> [ "a" ]
a = [ 1, 2, 3 ]
a.concat( [ 4, 5 ] )
a #=> [ 1, 2, 3, 4, 5 ]
a = [ 1, 2 ]
a.concat(a, a)... -
Array
# concat(other) -> self (12203.0) -
配列 other を自身の末尾に破壊的に連結します。
...other を自身の末尾に破壊的に連結します。
@param other 自身と連結したい配列を指定します。
//emlist[例][ruby]{
array = [1, 2]
a = [3, 4]
array.concat a
p array # => [1, 2, 3, 4]
p a # => [3, 4] # こちらは変わらない
//}......列 other を自身の末尾に破壊的に連結します。
@param other 自身と連結したい配列を指定します。
//emlist[例][ruby]{
array = [1, 2]
a = [3, 4]
array.concat a
p array # => [1, 2, 3, 4]
p a # => [3, 4] # こちらは変わらない
//}... -
Binding
# source _ location -> [String , Integer] (12203.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}... -
Enumerable
# collect _ concat -> Enumerator (12203.0) -
各要素をブロックに渡し、その返り値を連結した配列を返します。
...ックに渡し、その返り値を連結した配列を返します。
ブロックの返り値は基本的に配列を返すべきです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
[[1,2], [3,4]].flat_map{|i| i.map{|j| j*2}} # => [2,4,6,8]
//}... -
Enumerable
# collect _ concat {| obj | block } -> Array (12203.0) -
各要素をブロックに渡し、その返り値を連結した配列を返します。
...ックに渡し、その返り値を連結した配列を返します。
ブロックの返り値は基本的に配列を返すべきです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
[[1,2], [3,4]].flat_map{|i| i.map{|j| j*2}} # => [2,4,6,8]
//}... -
Enumerator
:: Lazy # collect _ concat {|item| . . . } -> Enumerator :: Lazy (12203.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
...ブロックの実行結果をひとつに繋げたものに対してイテレートするような
Enumerator::Lazy のインスタンスを返します。
//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した......force メソッドを持つ (例:Enumerator::Lazy) とき
それ以外のときは、x は分解されず、そのままの値として使われます。
//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}
@raise ArgumentError ブロックを指定しなか......った場合に発生します。
@see Enumerable#flat_map...