747件ヒット
[1-100件を表示]
(0.098秒)
クラス
- Array (19)
- Binding (8)
- Dir (85)
- Enumerator (27)
- Exception (22)
- Fiber (3)
- File (11)
-
File
:: Stat (33) - IO (33)
- LoadError (11)
- Method (11)
- Module (11)
- Object (36)
- Random (22)
- Range (23)
-
RubyVM
:: InstructionSequence (44) - String (22)
- Thread (11)
-
Thread
:: Queue (18) -
Thread
:: SizedQueue (27) - Time (21)
- UnboundMethod (11)
モジュール
- Enumerable (66)
- FileTest (44)
- Kernel (99)
キーワード
-
$ " (11) -
$ -I (11) -
$ : (11) -
$ LOADED _ FEATURES (11) -
$ LOAD _ PATH (11) - <=> (11)
- == (11)
- ConditionVariable (9)
- DATA (11)
- Fiber (11)
-
SCRIPT
_ LINES _ _ (11) - SizedQueue (9)
- all? (11)
- any? (11)
- autoload (22)
-
backtrace
_ locations (11) - ceil (5)
-
compile
_ option (11) - crypt (11)
- deq (9)
-
each
_ with _ index (22) - empty? (8)
- entries (17)
- fcntl (11)
- fdatasync (11)
-
first
_ lineno (11) - floor (5)
- flush (11)
-
handle
_ interrupt (11) - irb (8)
- load (11)
- new (33)
-
num
_ waiting (9) - of (11)
- open (44)
- pack (19)
- path (22)
- pop (9)
- produce (5)
- rand (22)
- read (11)
-
require
_ relative (11) - round (11)
- setgid? (11)
- setuid? (11)
- shift (18)
- size? (11)
- socket? (11)
-
source
_ location (22) - sticky? (11)
- symlink? (11)
-
to
_ a (28) - transfer (3)
- unpack (11)
-
with
_ index (22) -
yield
_ self (14)
検索結果
先頭5件
-
Kernel
. # require(feature) -> bool (32227.0) -
Ruby ライブラリ feature をロードします。拡張子補完を行い、 同じファイルの複数回ロードはしません。
...字列です。
@raise LoadError ロードに失敗した場合に発生します。
//emlist[例][ruby]{
$LOADED_FEATURES.grep(/prime/).size # => 0
require "prime" # => true
$LOADED_FEATURES.grep(/prime/).size # => 1
require "prime" # => false
begin
require "invalid"
rescue LoadError......=> e
e.message # => "cannot load such file -- invalid"
end
//}
@see Kernel.#load,Kernel.#autoload,Kernel.#require_relative... -
Kernel
. # require _ relative(relative _ feature) -> bool (20249.0) -
現在のファイルからの相対パスで require します。
...の相対パスで require します。
require File.expand_path(relative_feature, File.dirname(__FILE__))
とほぼ同じです。
Kernel.#eval などで文字列を評価した場合に、そこから
require_relative を呼出すと必ず失敗します。
@param relative_feature ファイ......ル名の文字列です。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require
=== require と load のスコープ
ローカル変数はファイル間では共有されません。ですので、
ロードしたライブラリのローカル変数を
ロー......プの扱い方はKernel.#loadでも同様です。
//emlist[例][ruby]{
# ---------- some.rb -----------
$a = 1
@a = 1
A = 1
a = 1
# ---------- end some.rb -------
require 'some'
p $a #=> 1
p @a #=> 1
p A #=> 1
p a # undefined local variable or method `a' for #<Object:0x294f9ec @a=1> (NameError)... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (17208.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...ception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if D......aise "#{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:i......n `<main>'"]
//}
@see Exception#backtrace... -
Binding
# irb -> object (17108.0) -
REPLのセッションを開始します。
...REPLのセッションを開始します。
2.5.0 からは require 'irb' せずに直接 binding.irb を呼び出しても使えるようになりました。
@see irb... -
RubyVM
:: InstructionSequence # first _ lineno -> Integer (17108.0) -
self が表す命令シーケンスの 1 行目の行番号を返します。
...の 1 行目の行番号を返します。
例1:irb で実行した場合
RubyVM::InstructionSequence.compile('num = 1 + 2').first_lineno
# => 1
例2:
# /tmp/method.rb
require "foo-library"
def foo
p :foo
end
RubyVM::InstructionSequence.of(method(:foo)).first_lineno
# => 2... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (14220.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emlist[例][ruby]{
[5, 10, 15].each_wit......h_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}
@see Enumerator#with_index... -
Kernel
$ $ -I -> [String] (14145.0) -
Rubyライブラリをロードするときの検索パスです。
...です。
Kernel.#load や Kernel.#require
がファイルをロードする時に検索するディレクトリのリストを含む配列です。
起動時にはコマンドラインオプション -I で指定したディレクトリ、
環境変数 RUBYLIB の値、
コンパイル時に指......下に典型的な UNIX システム上でのロードパスを示します。
-I で指定したパス
環境変数 RUBYLIB の値
/usr/local/lib/ruby/site_ruby/VERSION サイト固有、バージョン依存のライブラリ
/usr/local/lib/ruby/site_ruby/VERSION/ARCH サイト......ラリ
/usr/local/lib/ruby/site_ruby サイト固有ライブラリ
/usr/local/lib/ruby/VERSION 標準ライブラリ
/usr/local/lib/ruby/VERSION/ARCH 標準、システム依存、拡張ライブラリ
上記表中の VERSION は Ruby のバージ... -
Enumerable
# each _ with _ index(*args) -> Enumerator (14120.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま渡されます。
//emlist[例][ruby]{
[5, 10, 15].each_wit......h_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}
@see Enumerator#with_index... -
Enumerator
# with _ index(offset = 0) -> Enumerator (14120.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...す。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["f......にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (14120.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...す。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["f......にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。...