ライブラリ
- ビルトイン (703)
- csv (22)
- forwardable (66)
- json (22)
-
minitest
/ spec (1) -
minitest
/ unit (2) - pp (11)
- prime (66)
-
rdoc
/ context (11) -
rubygems
/ command _ manager (11) - singleton (22)
- syslog (11)
-
webrick
/ httpservlet / abstract (11) -
webrick
/ httpservlet / prochandler (11)
クラス
- BasicObject (44)
- CSV (22)
-
Gem
:: CommandManager (11) -
JSON
:: Parser (22) - Method (11)
- Module (220)
- Object (221)
- Prime (66)
-
RDoc
:: Context (11) - UnboundMethod (131)
-
WEBrick
:: HTTPServlet :: AbstractServlet (11) -
WEBrick
:: HTTPServlet :: ProcHandler (11)
モジュール
- Enumerable (22)
- Forwardable (66)
- Kernel (44)
-
MiniTest
:: Assertions (2) - Singleton (11)
- Syslog (11)
オブジェクト
- main (22)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - == (11)
- === (22)
- Marshal フォーマット (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- Ruby用語集 (11)
- Singleton (11)
- TYPES (11)
- arity (11)
-
assert
_ instance _ of (1) -
assert
_ kind _ of (1) - bind (11)
-
bind
_ call (10) - class (11)
-
class
_ eval (22) -
class
_ variables (11) - clone (11)
- constants (22)
-
def
_ delegator (11) -
def
_ delegators (11) -
def
_ instance _ delegator (11) -
def
_ instance _ delegators (11) -
define
_ method (44) - delegate (11)
- drb (11)
- each (22)
- eql? (11)
- eval (22)
-
get
_ instance (22) -
global
_ variables (11) - grep (22)
-
initialize
_ copy (11) - inspect (11)
-
instance
_ delegate (11) -
instance
_ eval (22) -
instance
_ exec (11) -
instance
_ method (11) -
instance
_ methods (11) -
instance
_ of? (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) -
int
_ from _ prime _ division (11) - irb (11)
-
irb
/ completion (11) -
is
_ a? (11) -
kind
_ of? (11) -
local
_ variables (11) - method (11)
-
method
_ added (11) - methods (11)
-
module
_ eval (22) -
must
_ be _ instance _ of (1) - name (11)
- new (11)
-
original
_ name (11) - owner (11)
- parameters (11)
- parse (11)
-
pretty
_ print _ instance _ variables (11) - prime? (11)
-
prime
_ division (11) -
private
_ instance _ methods (11) -
private
_ methods (11) -
protected
_ instance _ methods (11) -
protected
_ methods (11) -
public
_ instance _ method (11) -
public
_ instance _ methods (11) -
public
_ method (11) -
public
_ methods (11) -
remove
_ class _ variable (11) -
remove
_ const (11) -
remove
_ instance _ variable (11) -
respond
_ to? (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) -
singleton
_ method (11) -
singleton
_ method _ undefined (11) -
source
_ location (11) -
to
_ s (11) -
undef
_ method (11) - クラス/メソッドの定義 (11)
- 変数と定数 (11)
検索結果
先頭5件
-
CSV
. instance(data = $ stdout , options = Hash . new) -> CSV (18214.0) -
このメソッドは CSV.new のように CSV のインスタンスを返します。 しかし、返される値は Object#object_id と与えられたオプションを キーとしてキャッシュされます。
.../emlist[例][ruby]{
require "csv"
options = { headers: true }
text =<<-EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
csv = CSV.instance(text, options)
csv2 = CSV.instance(text, options)
csv.object_id == csv2.object_id # => true
print csv.read... -
CSV
. instance(data = $ stdout , options = Hash . new) {|csv| . . . } -> object (18214.0) -
このメソッドは CSV.new のように CSV のインスタンスを返します。 しかし、返される値は Object#object_id と与えられたオプションを キーとしてキャッシュされます。
.../emlist[例][ruby]{
require "csv"
options = { headers: true }
text =<<-EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
csv = CSV.instance(text, options)
csv2 = CSV.instance(text, options)
csv.object_id == csv2.object_id # => true
print csv.read... -
Gem
:: CommandManager . instance -> Gem :: CommandManager (18201.0) -
自身をインスタンス化します。
自身をインスタンス化します。 -
Prime
. instance -> Prime (18201.0) -
Prime のデフォルトのインスタンスを返します。
Prime のデフォルトのインスタンスを返します。 -
Singleton
. instance -> object (18201.0) -
そのクラスの唯一のインスタンスを返します。 最初に呼ばれたときはそのインスタンスを生成します。
そのクラスの唯一のインスタンスを返します。
最初に呼ばれたときはそのインスタンスを生成します。
Singleton を include したクラスで定義されますので、
正確には Singleton モジュールのメソッドではありません。 -
Syslog
. # instance -> self (18201.0) -
selfを返します。(旧版との互換性のため)
selfを返します。(旧版との互換性のため) -
Module
# instance _ methods(inherited _ too = true) -> [Symbol] (6297.0) -
そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。
...) end
end
# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods(false)
p Foo.protected_instance_methods(false)
class Bar < Foo
end
//}
実行結果
[:protected_foo, :public_fo......p Bar.instance_methods(true) - Object.instance_methods(true)
p Bar.public_instance_methods(true) - Object.public_instance_methods(true)
p Bar.private_instance_methods(true) - Object.private_instance_methods(true)
p Bar.protected_instance_methods(true) - Object.protected_instance_metho... -
BasicObject
# instance _ eval {|obj| . . . } -> object (6268.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...では instance_eval の外側のスコープと、ブロックの評価ではそのブロックの外側のスコープと、共有します。
メソッド定義の中で instance_eval でメソッドを定義した場合は、囲むメソッドが実行されたときに
初めて instance_eval......ド定義のネストと同じです。
d:spec/def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、......'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッドも呼び出せる
some.instance_eval 'raise' # ..:10: (eval):1: (RuntimeError)
messg = 'unknown'
some.instance_eval 'raise messg','file.rb',999 # file.rb:9... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (6268.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...では instance_eval の外側のスコープと、ブロックの評価ではそのブロックの外側のスコープと、共有します。
メソッド定義の中で instance_eval でメソッドを定義した場合は、囲むメソッドが実行されたときに
初めて instance_eval......ド定義のネストと同じです。
d:spec/def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、......'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッドも呼び出せる
some.instance_eval 'raise' # ..:10: (eval):1: (RuntimeError)
messg = 'unknown'
some.instance_eval 'raise messg','file.rb',999 # file.rb:9... -
Object
# instance _ variable _ defined?(var) -> bool (6237.0) -
インスタンス変数 var が定義されていたら真を返します。
..., @b = p1, p2
end
end
fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=> true
p fred.instance_variable_defined?("@c") #=> false
//}
@see Object#instance_variable_get,Object#instance_variable_set,Object#instance_variables...