別のキーワード
クラス
- BasicObject (48)
- CSV (24)
-
JSON
:: Parser (24) - Method (12)
- Module (216)
- Object (192)
- UnboundMethod (144)
モジュール
- Enumerable (24)
- Kernel (48)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - == (12)
- === (24)
- Marshal フォーマット (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Prime (12)
- Ruby プログラムの実行 (12)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
- UnboundMethod (12)
- arity (12)
- bind (12)
-
bind
_ call (12) - class (12)
-
class
_ eval (24) -
class
_ variables (12) - clone (12)
- constants (24)
-
define
_ method (24) - drb (12)
- eql? (12)
- eval (24)
-
global
_ variables (12) - grep (24)
-
initialize
_ copy (12) - inspect (12)
-
instance
_ eval (24) -
instance
_ exec (12) -
instance
_ method (12) -
instance
_ methods (12) -
instance
_ of? (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
instance
_ variable _ set (12) -
instance
_ variables (12) - irb (12)
-
is
_ a? (12) -
kind
_ of? (12) -
local
_ variables (12) - method (12)
-
method
_ added (12) - methods (12)
-
module
_ eval (24) - name (12)
- new (12)
-
original
_ name (12) - owner (12)
- parameters (12)
- parse (12)
-
private
_ instance _ methods (12) -
public
_ instance _ method (12) -
public
_ method (12) -
remove
_ class _ variable (12) -
remove
_ const (12) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
rubygems
/ command _ manager (12) -
singleton
_ method (12) -
singleton
_ method _ undefined (12) -
source
_ location (12) -
to
_ s (12) -
undef
_ method (12) - クラス/メソッドの定義 (12)
- パターンマッチ (4)
- 変数と定数 (12)
検索結果
先頭5件
-
rubygems
/ command _ manager (26012.0) -
gem コマンドによってサポートされているサブコマンドを管理するライブラリです。
...a rubygems_plugin.rb
file in an installed gem. You should register your command against the
Gem::CommandManager instance, like this:
# file rubygems_plugin.rb
require 'rubygems/command_manager'
class Gem::Commands::EditCommand < Gem::Command
# ...
end
Gem::CommandManager.instance.... -
CSV
. instance(data = $ stdout , options = Hash . new) -> CSV (18120.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.obje... -
CSV
. instance(data = $ stdout , options = Hash . new) {|csv| . . . } -> object (18120.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.obje... -
Module
# instance _ methods(inherited _ too = true) -> [Symbol] (6185.0) -
そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。
...1][ruby]{
class Foo
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end
# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_metho......ds(false)
p Foo.protected_instance_methods(false)
class Bar < Foo
end
//}
実行結果
[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]
//emlist[例2][ruby]{
class Bar
private; def private_foo() end
protected; def protected_foo() end
publi......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 (6180.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...では instance_eval の外側のスコープと、ブロックの評価ではそのブロックの外側のスコープと、共有します。
メソッド定義の中で instance_eval でメソッドを定義した場合は、囲むメソッドが実行されたときに
初めて instance_eval......ド定義のネストと同じです。
d:spec/def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、......//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッドも呼び出せる
some.instance_eval 'raise' # ..... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (6180.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...では instance_eval の外側のスコープと、ブロックの評価ではそのブロックの外側のスコープと、共有します。
メソッド定義の中で instance_eval でメソッドを定義した場合は、囲むメソッドが実行されたときに
初めて instance_eval......ド定義のネストと同じです。
d:spec/def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、......//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッドも呼び出せる
some.instance_eval 'raise' # ..... -
Object
# instance _ variable _ defined?(var) -> bool (6143.0) -
インスタンス変数 var が定義されていたら真を返します。
...//emlist[][ruby]{
class Fred
def initialize(p1, p2)
@a, @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... -
Object
# instance _ variable _ get(var) -> object | nil (6143.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...t[][ruby]{
class Foo
def initialize
@foo = 1
end
end
obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instance_variable_get(:@bar) #=> nil
//}
@see Object#instance_variable_set,Object#instance_variables,Object#instance_var... -
Object
# instance _ variable _ set(var , value) -> object (6143.0) -
オブジェクトのインスタンス変数 var に値 value を設定します。
...value を返します。
//emlist[][ruby]{
obj = Object.new
p obj.instance_variable_set("@foo", 1) #=> 1
p obj.instance_variable_set(:@foo, 2) #=> 2
p obj.instance_variable_get(:@foo) #=> 2
//}
@see Object#instance_variable_get,Object#instance_variables,Object#instance_variable_defined?...