クラス
-
ARGF
. class (75) - Array (48)
- BasicObject (24)
- Binding (12)
- Complex (24)
- Exception (24)
- File (36)
- IO (468)
- LoadError (12)
- Module (144)
- Object (156)
- Proc (19)
- String (60)
- SystemExit (12)
- Thread (72)
- TracePoint (12)
- UncaughtThrowError (22)
キーワード
-
$ ! (12) -
$ & (12) -
$ & # 39; (12) -
$ -F (12) -
$ -I (6) -
$ -p (12) -
$ 1 (12) -
$ 10 (12) -
$ 11 (12) -
$ 2 (12) -
$ 3 (12) -
$ 4 (12) -
$ 5 (12) -
$ 6 (12) -
$ 7 (12) -
$ 8 (12) -
$ 9 (12) -
$ : (6) -
$ ; (12) -
$ > (12) -
$ ? (12) -
$ LOAD _ PATH (12) -
$ PROGRAM _ NAME (12) -
$ ` (12) -
$ stdin (12) -
$ stdout (12) -
$ ~ (12) - % (12)
- ARGF (12)
- Array (12)
- Complex (36)
- DATA (12)
- Float (12)
- Integer (12)
- Proc (12)
- Rational (7)
-
SCRIPT
_ LINES _ _ (12) - String (12)
- TracePoint (12)
-
_ _ callee _ _ (12) -
_ _ method _ _ (12) - abort (24)
-
add
_ trace _ func (12) - ancestors (12)
-
at
_ exit (12) - autoload (24)
- autoload? (12)
- binding (12)
- binread (12)
- binwrite (12)
- caller (36)
-
caller
_ locations (24) - catch (24)
- chomp (12)
- chop (12)
- class (12)
-
class
_ eval (24) -
const
_ defined? (12) - constants (24)
-
defined
_ class (12) - exception (24)
- exec (48)
- exit (24)
- exit! (12)
- fail (36)
-
for
_ fd (12) - foreach (24)
- fork (24)
- format (12)
- freeze (12)
- gets (39)
-
global
_ variables (12) - gsub (36)
- hex (12)
- identical? (12)
- include (12)
- inspect (12)
-
instance
_ eval (24) -
instance
_ variables (12) - kill (24)
- lambda (18)
- load (12)
-
local
_ variables (12) - loop (24)
- method (12)
-
module
_ eval (24) - new (43)
- oct (12)
- open (72)
- p (12)
- path (12)
- popen (168)
- pp (8)
- print (36)
- printf (48)
- proc (19)
-
public
_ instance _ method (12) - putc (36)
- puts (36)
- raise (48)
- read (36)
- readline (12)
- readlines (48)
- rect (12)
- rectangular (12)
-
remove
_ const (12) - reopen (36)
-
require
_ relative (12) - sample (48)
- select (24)
- send (24)
-
set
_ trace _ func (24) - sleep (24)
- sprintf (12)
- srand (24)
- status (12)
- sub (24)
- sysopen (12)
- system (48)
- tag (11)
- terminate (12)
- test (24)
-
to
_ a (12) -
to
_ ary (12) -
to
_ f (12) -
to
_ i (12) -
to
_ int (12) -
to
_ str (12) -
trace
_ var (36) - trap (24)
-
untrace
_ var (12) - value (11)
- warn (8)
- write (24)
検索結果
先頭5件
-
Module
# constants(inherit = true) -> [Symbol] (38.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...ません。
@param inherit true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables......nd
class Bar
BAR = 1
# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []
#......ネストしたクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constants には含まれる
# (クラス Baz も Bar の定数なので同様)
p Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}... -
Object
# send(name , *args) -> object (38.0) -
オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。
...ドを呼び出せます。
d:spec/def#limit も参照してください。
public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。
@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッド......に渡す引数です。
//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby".send(:sub,/./,"R") #=> "Ruby"
class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end
# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの......ーバは任意(Foo クラスのインスタンスである必要もない)
p Foo.new.send(methods[1]) # => "foo"
p Foo.new.send(methods[2]) # => "bar"
p Foo.new.send(methods[3]) # => "baz"
//}
@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method... -
Object
# send(name , *args) { . . . . } -> object (38.0) -
オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。
...ドを呼び出せます。
d:spec/def#limit も参照してください。
public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。
@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッド......に渡す引数です。
//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby".send(:sub,/./,"R") #=> "Ruby"
class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end
# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの......ーバは任意(Foo クラスのインスタンスである必要もない)
p Foo.new.send(methods[1]) # => "foo"
p Foo.new.send(methods[2]) # => "bar"
p Foo.new.send(methods[3]) # => "baz"
//}
@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method... -
Module
# ancestors -> [Class , Module] (32.0) -
クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。
...先順位順に配列に格納して返します。
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}
@see Module#included_modules... -
Module
# const _ defined?(name , inherit = true) -> bool (32.0) -
モジュールに name で指定される名前の定数が定義されている時真 を返します。
...とができます。
@param name String, Symbol で指定される定数名。
@param inherit false を指定するとスーパークラスや include したモジュールで
定義された定数は対象にはなりません。
//emlist[例][ruby]{
module Kernel
FOO = 1
end
# Object......include したモジュールの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true
module Bar
BAR = 1
end
class Object
include Bar
end
# ユーザ定義のモジュールに対しても同様
p Object.const_defined?(:BAR) # => true
class Baz
include Bar
end
#......Object 以外でも同様になった
# 第二引数のデフォルト値が true であるため
p Baz.const_defined?(:BAR) # => true
# 第二引数を false にした場合
p Baz.const_defined?(:BAR, false) # => false
//}... -
Thread
# exit -> self (32.0) -
スレッドの実行を終了させます。終了時に ensure 節が実行されます。
...スを Kernel.#exit(0)
により終了します。
Kernel.#exit と違い例外 SystemExit を発生しません。
th1 = Thread.new do
begin
sleep 10
ensure
p "this will be displayed"
end
end
sleep 0.1
th1.kill
#=> "this will be displayed"
@see Kernel.#exit,... -
Thread
# kill -> self (32.0) -
スレッドの実行を終了させます。終了時に ensure 節が実行されます。
...スを Kernel.#exit(0)
により終了します。
Kernel.#exit と違い例外 SystemExit を発生しません。
th1 = Thread.new do
begin
sleep 10
ensure
p "this will be displayed"
end
end
sleep 0.1
th1.kill
#=> "this will be displayed"
@see Kernel.#exit,... -
Thread
# terminate -> self (32.0) -
スレッドの実行を終了させます。終了時に ensure 節が実行されます。
...スを Kernel.#exit(0)
により終了します。
Kernel.#exit と違い例外 SystemExit を発生しません。
th1 = Thread.new do
begin
sleep 10
ensure
p "this will be displayed"
end
end
sleep 0.1
th1.kill
#=> "this will be displayed"
@see Kernel.#exit,... -
ARGF (26.0)
-
スクリプトに指定した引数 (Object::ARGV を参照) をファイル名とみなして、 それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。 ARGV が空なら標準入力を対象とします。 ARGV を変更すればこのオブジェクトの動作に影響します。
...に影響します。
//emlist[][ruby]{
while line = ARGF.gets
# do something
end
//}
は、
//emlist[][ruby]{
while argv = ARGV.shift
File.open(argv) {|file|
while line = file.gets
# do something
end
}
end
//}
のように動作します。
ARGF を処理するごとに ARG......ruby]{
ARGV.replace %w(/tmp/foo /tmp/bar)
ARGF.each {|line|
# 処理中の ARGV の内容を表示
p [ARGF.filename, ARGV]
ARGF.skip
}
# => ["/tmp/foo", ["/tmp/bar"]]
# ["/tmp/bar", []]
# 最後まで読んだ後 (ARGV が空) の動作
p ARGF.gets # => nil
p ARGF.filenam......e # => "-"
//}
Kernel.#gets など一部の組み込み関数は
ARGF.gets などこのオブジェクトをレシーバとしたメソッドの省略形です。
また、ARGF は ARGF.class クラスのインスタンスです。
各メソッドの詳細は ARGF.class を参照してくださ...