216件ヒット
[1-100件を表示]
(0.145秒)
クラス
- Method (12)
- Module (12)
- Object (36)
- OptionParser (144)
- UnboundMethod (12)
キーワード
- arity (12)
-
const
_ source _ location (12) - on (144)
-
public
_ method (12) -
singleton
_ class (12) -
source
_ location (12)
検索結果
先頭5件
-
Object
# class -> Class (18299.0) -
レシーバのクラスを返します。
...レシーバのクラスを返します。
//emlist[][ruby]{
p "ruby".class #=> String
p 100.class #=> Integer
p ARGV.class #=> Array
p self.class #=> Object
p Class.class #=> Class
p Kernel.class #=> Module
//}
@see Class#superclass,Object#kind_of?,Object#instance_of?... -
Object
# singleton _ class -> Class (6281.0) -
レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。
...れ NilClass, TrueClass,
FalseClass を返します。
@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。
//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
nil.singleton_class......#=> NilClass
//}
@see Object#class... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (358.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義され......なかった場合は空の配列を返します。
//emlist[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end
module M # line 6
C3 = 3
end
class B < A # line 10
include M
C4 = 4
end
class A # 継続して A を定義する
C2 = 8 # 定数を再定義する......-- Object は継承していないが追加で modules をチェックする
p Object.const_source_location('A::C1') # => ["test.rb", 2] -- ネストの指定もサポートしている
p Object.const_source_location('String') # => [] -- 定数は C のコードで定義されている
//}... -
Method
# source _ location -> [String , Integer] | nil (334.0) -
ソースコードのファイル名と行番号を配列で返します。
...列で返します。
その手続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
@see Proc#source_location
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----... -
OptionParser
# on(long , klass = String , desc = "") {|v| . . . } -> self (311.0) -
オプションを取り扱うためのブロックを自身に登録します。 ブロックはコマンドラインのパース時に、オプションが指定されていれば呼ばれます。
...れてから、ブロックに渡されます。
opts.on("-w", "--width N", Integer){|w|
p w.class #=> Integer
}
# ruby command --width=32
opts.on("-o", "--overwrite VALUE", TrueClass){|boolean| ...}
# ruby command --overwrite yes
@param short ショートオプションを表す文......Object
オプションの引数は変換されません。
: String
オプションの引数は変換されません。ただし、空文字列を指定すると
OptionParser::InvalidArgument が発生します。
: Integer
Integer オブジェクトに変換されます。"0b1"、"07"、"99"......は Integer オブジェクトに、実数の場合は Float オブジェクトに
変換されます。
: OptionParser::DecimalInteger
Integer オブジェクトに変換されます。10進数の整数の整数のフォーマットの
みを指定できます。
: OptionParser::OctalInteger... -
OptionParser
# on(short , klass = String , desc = "") {|v| . . . } -> self (311.0) -
オプションを取り扱うためのブロックを自身に登録します。 ブロックはコマンドラインのパース時に、オプションが指定されていれば呼ばれます。
...れてから、ブロックに渡されます。
opts.on("-w", "--width N", Integer){|w|
p w.class #=> Integer
}
# ruby command --width=32
opts.on("-o", "--overwrite VALUE", TrueClass){|boolean| ...}
# ruby command --overwrite yes
@param short ショートオプションを表す文......Object
オプションの引数は変換されません。
: String
オプションの引数は変換されません。ただし、空文字列を指定すると
OptionParser::InvalidArgument が発生します。
: Integer
Integer オブジェクトに変換されます。"0b1"、"07"、"99"......は Integer オブジェクトに、実数の場合は Float オブジェクトに
変換されます。
: OptionParser::DecimalInteger
Integer オブジェクトに変換されます。10進数の整数の整数のフォーマットの
みを指定できます。
: OptionParser::OctalInteger... -
OptionParser
# on(short , long , klass = String , desc = "") {|v| . . . } -> self (311.0) -
オプションを取り扱うためのブロックを自身に登録します。 ブロックはコマンドラインのパース時に、オプションが指定されていれば呼ばれます。
...れてから、ブロックに渡されます。
opts.on("-w", "--width N", Integer){|w|
p w.class #=> Integer
}
# ruby command --width=32
opts.on("-o", "--overwrite VALUE", TrueClass){|boolean| ...}
# ruby command --overwrite yes
@param short ショートオプションを表す文......Object
オプションの引数は変換されません。
: String
オプションの引数は変換されません。ただし、空文字列を指定すると
OptionParser::InvalidArgument が発生します。
: Integer
Integer オブジェクトに変換されます。"0b1"、"07"、"99"......は Integer オブジェクトに、実数の場合は Float オブジェクトに
変換されます。
: OptionParser::DecimalInteger
Integer オブジェクトに変換されます。10進数の整数の整数のフォーマットの
みを指定できます。
: OptionParser::OctalInteger... -
UnboundMethod
# arity -> Integer (168.0) -
メソッドが受け付ける引数の数を返します。
...します。C 言語レベルで実装されたメソッドが可変長引数を
受け付ける場合、-1 を返します。
//emlist[例][ruby]{
class C
def one; end
def two(a); end
def three(*a); end
def four(a, b); end
def five(a, b, *c); end
def six(a, b, *c, &d); end
end......).arity #=> 2
p C.instance_method(:five).arity #=> -3
p C.instance_method(:six).arity #=> -3
String.instance_method(:size).arity #=> 0
String.instance_method(:replace).arity #=> 1
String.instance_method(:squeeze).arity #=> -1
String.instance_method(:count).arity #=> -1
//}... -
OptionParser
# on(long , pat = / . * / , desc = "") {|v| . . . } -> self (76.0) -
オプションを取り扱うためのブロックを自身に登録します。 ブロックはコマンドラインのパース時に、オプションが指定されていれば呼ばれます。
...dArgument が parse 実行時に投げられます。
opts.on("--username VALUE", /[a-zA-Z0-9_]+/){|name| ...}
# ruby command --username=ruby_user
# ruby command --username=ruby.user #=> Error
@param short ショートオプションを表す文字列を指定します。
@param long ロン...