480件ヒット
[1-100件を表示]
(0.059秒)
別のキーワード
種類
- インスタンスメソッド (444)
- 定数 (24)
- 特異メソッド (12)
キーワード
- === (12)
- FALSE (8)
- NIL (8)
- TRUE (8)
-
_ dump (12) -
define
_ singleton _ method (24) - display (12)
- extend (12)
- initialize (12)
-
initialize
_ copy (12) - inspect (12)
-
instance
_ of? (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
instance
_ variables (12) -
is
_ a? (12) -
kind
_ of? (12) -
marshal
_ dump (12) -
marshal
_ load (12) - methods (12)
-
pretty
_ print (12) -
pretty
_ print _ cycle (12) -
public
_ method (12) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ class (12) -
singleton
_ method (12) -
singleton
_ methods (12) -
to
_ ary (12) -
to
_ hash (12) -
to
_ int (12) -
to
_ proc (12) -
to
_ regexp (12) -
to
_ s (12) -
to
_ str (12) -
yaml
_ tag (12)
検索結果
先頭5件
-
Object
# class -> Class (18269.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 (6245.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... -
Object
# singleton _ methods(inherited _ too = true) -> [Symbol] (121.0) -
そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。
...た特異メソッドとは Object#extend によって追加された特異メソッドや、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。
singleton_methods(false) は、Object#methods(false) と同じで......1][ruby]{
Parent = Class.new
class <<Parent
private; def private_class_parent() end
protected; def protected_class_parent() end
public; def public_class_parent() end
end
Foo = Class.new(Parent)
class <<Foo
private; def private_class_foo() end
protected; def protected_class_foo()......end
public; def public_class_foo() end
end
module Bar
private; def private_bar() end
protected; def protected_bar() end
public; def public_bar() end
end
obj = Foo.new
class <<obj
include Bar
private; def private_self() end
protected; def protected_self() end
public... -
Object
:: FALSE -> FalseClass (107.0) -
非推奨です。代表的な偽の値。false と同じ。
...の値。false と同じ。
この定数は過去との互換性のために提供されています。擬似変数 false を使ってください。
Ruby では false と nil が偽として扱われます。
偽でない値(false でも nil でもない値) は全て真とみなされます。... -
Object
:: NIL -> NilClass (107.0) -
非推奨です。 nil と同じ。
...奨です。 nil と同じ。
この定数は過去との互換性のために提供されています。擬似変数 nil を使ってください。
Ruby では false と nil が偽として扱われます。
偽でない値(false でも nil でもない値) は全て真とみなされます。... -
Object
:: TRUE -> TrueClass (107.0) -
非推奨です。代表的な真の値。true と同じ。
...の値。true と同じ。
この定数は過去との互換性のために提供されています。擬似変数 true を使ってください。
Ruby では false と nil が偽として扱われます。
偽でない値(false でも nil でもない値) は全て真とみなされます。... -
Object
# respond _ to?(name , include _ all = false) -> bool (49.0) -
オブジェクトがメソッド name を持つとき真を返します。
...は
Rubyの組み込みライブラリや標準ライブラリなど、C言語で実装されているメソッドのみです。
Rubyで実装されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#resp......ます。省略した場合
は false(含めない) を指定した事になります。
//emlist[][ruby]{
class F
def hello
"Bonjour"
end
end
class D
private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]
list.each{|it| puts it.hello if it.respond_to?(:he......ate_method
raise NotImplementedError.new
end
def finish
puts "finish"
end
end
class ImplTemplateMethod
include Template
def template_method
"implement template_method"
end
end
class NotImplTemplateMethod
include Template
# not implement template_method
end
puts ImplT... -
Object
# ===(other) -> bool (43.0) -
case 式で使用されるメソッドです。d:spec/control#case も参照してください。
...ルトでは内部で Object#== を呼び出します。
when 節の式をレシーバーとして === を呼び出すことに注意してください。
また Enumerable#grep でも使用されます。
@param other 比較するオブジェクトです。
//emlist[][ruby]{
age = 12
# (0..2).=......when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end
puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's wo......rld>
//}
@see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep... -
Object
# initialize(*args , &block) -> object (37.0) -
ユーザ定義クラスのオブジェクト初期化メソッド。
...。
このメソッドは Class#new から新しく生成されたオブ
ジェクトの初期化のために呼び出されます。他の言語のコンストラクタに相当します。
デフォルトの動作ではなにもしません。
initialize には
Class#new に与えられた引数......@param block 初期化時のブロック引数です。必須ではありません。
//emlist[][ruby]{
class Foo
def initialize name
puts "initialize Foo"
@name = name
end
end
class Bar < Foo
def initialize name, pass
puts "initialize Bar"
super name
@pass = pass
end......end
it = Bar.new('myname','0500')
p it
#=> initialize Bar
# initialize Foo
# #<Bar:0x2b68f08 @name="myname", @pass="0500">
//}
@see Class#new... -
Object
. yaml _ tag(tag) -> () (37.0) -
クラスと tag の間を関連付けます。
... Ruby のオブジェクトに
変換したりその逆をしたりすることができます。
@param tag 対象のクラスに関連付けるタグの文字列
=== Example
require 'psych'
class Foo
def initialize(x)
@x = x
end
attr_reader :x
end
# Dumps Ruby......w(3))
# =>
# --- !ruby/object:Foo
# x: 3
# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013:foo")
# ... and dumps the object of Foo class
Psych.dump(Foo.new(3), STDOUT)
# =>
# --- !<tag:example.com,2013:foo>
# x: 3
# Loads the object from the tagged YAML n...