るりまサーチ

最速Rubyリファレンスマニュアル検索!
156件ヒット [1-100件を表示] (0.085秒)

別のキーワード

  1. net/imap param
  2. win32ole win32ole_param
  3. win32ole_param output?
  4. win32ole_param retval?
  5. bodytypetext param

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

UnboundMethod#bind(obj) -> Method (18144.0)

self を obj にバインドした Method オブジェクトを生成して返します。

...成して返します。


@param obj 自身をバインドしたいオブジェクトを指定します。ただしバインドできるのは、
生成元のクラスかそのサブクラスのインスタンスのみです。

@raise TypeError objがbindできないオブジェクト...
...である場合に発生します

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo のインスタンスをレシ...
...ーバとする Method オブジェクトを生成
p m.bind(Foo.new) # => #<Method: Foo#foo>

# Foo のサブクラス Bar のインスタンスをレシーバとする Method
class Bar < Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>


# モジュールのイン...

Fiddle::Importer#bind(signature, *opts) { ... } -> Fiddle::Function (18136.0)

Ruby のブロックを C の関数で wrap し、その関数をモジュールに インポートします。

...Ruby のブロックを C の関数で wrap し、その関数をモジュールに
インポートします。

これでインポートされた関数はモジュール関数として定義されます。
また、Fiddle::Importer#[] で Fiddle::Function オブジェクトとして
取り出す...
...す。

@param signature 関数の名前とシネグチャ
@param opts オプション


require 'fiddle/import'

module M
extend Fiddle::Importer
dlload "libc.so.6"
typealias "size_t", "unsigned long"
extern "int qsort(void*, size_t, size_t, void*)"

bind
("int compa...

Proc#binding -> Binding (6219.0)

Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。

...Proc オブジェクトが保持するコンテキストを
Bind
ing オブジェクトで返します。

//emlist[例][ruby]{
def fred(param)
proc {}
end

sample_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}...

Binding#local_variable_set(symbol, obj) (3061.0)

引数 symbol で指定した名前のローカル変数に引数 obj を設定します。

...定します。

@param symbol ローカル変数名を Symbol オブジェクトで指定します。

@param obj 引数 symbol で指定したローカル変数に設定するオブジェクトを指定します。

//emlist[例][ruby]{
def foo
a = 1
bind
= binding
bind
.local_variable_set(:a...
..., 2) # set existing local variable `a'
bind
.local_variable_set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.local_variable_get(:b) # => 3
p a # => 2
p b...
...# => NameError
end
//}

このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。

//emlist[][ruby]{
bind
ing.eval("#{symbol} = #{obj}")
//}

@see Binding#local_variable_get, Binding#local_variable_defined?...

Binding#eval(expr, fname = __FILE__, lineno = 1) -> object (3041.0)

自身をコンテキストとし文字列 expr を Ruby プログラムとして評価しその結果を返します。 組み込み関数 Kernel.#eval を使って eval(expr, self, fname, lineno) とするのと同じです。

...とし文字列 expr を
Ruby
プログラムとして評価しその結果を返します。
組み込み関数 Kernel.#eval を使って
eval(expr, self, fname, lineno) とするのと同じです。

@param expr 評価したい式を文字列で与えます。

@param fname ファイル名を文...
...す。

@param lineno 行番号を整数で与えます。式 expr の先頭行の行番号が lineno であるかのように実行されます。

//emlist[例][ruby]{
def get_binding(str)
bind
ing
end
str = "hello"
p eval("str + ' Fred'") #=> "hello Fred"
p get_binding("bye"...

絞り込み条件を変える

Binding#local_variable_defined?(symbol) -> bool (3019.0)

引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。

...ue を、
そうでない場合に false を返します。

@param symbol ローカル変数名を Symbol オブジェクトで指定します。

//emlist[例][ruby]{
def foo
a = 1
bind
ing.local_variable_defined?(:a) # => true
bind
ing.local_variable_defined?(:b) # => false
end
//}

このメ...
...ソッドは以下のコードの短縮形です。

//emlist[][ruby]{
bind
ing.eval("defined?(#{symbol}) == 'local-variable'")
//}

@see Binding#local_variable_get, Binding#local_variable_set...

Binding#local_variable_get(symbol) -> object (3019.0)

引数 symbol で指定した名前のローカル変数に設定された値を返します。

...ます。

@param symbol ローカル変数名を Symbol オブジェクトで指定します。

@raise NameError 引数 symbol で指定したローカル変数が未定義の場合に発生します。

//emlist[例][ruby]{
def foo
a = 1
bind
ing.local_variable_get(:a) # => 1
bind
ing.local_v...
...ariable_get(:b) # => NameError
end
//}

このメソッドは以下のコードの短縮形です。

//emlist[][ruby]{
bind
ing.eval("#{symbol}")
//}

@see Binding#local_variable_set, Binding#local_variable_defined?...

Kernel#xmp(exps, bind = nil) -> XMP (142.0)

引数 exps で指定されたRuby のソースコードとその実行結果を、標準出力に行 ごとに交互に表示します。

...引数 exps で指定されたRuby のソースコードとその実行結果を、標準出力に行
ごとに交互に表示します。

@param exps 評価するRuby のソースコードを文字列で指定します。

@param bind Binding オブジェクトを指定します。省略した場...
...合は、最
後に実行した XMP#puts、Kernel#xmp の
Bind
ing を使用します。まだ何も実行していない場合は
Object::TOPLEVEL_BINDING を使用します。...

ERB#result(b=TOPLEVEL_BINDING) -> String (113.0)

ERB を b の binding で実行し、結果の文字列を返します。

...ERB を b の binding で実行し、結果の文字列を返します。

@param b eRubyスクリプトが実行されるときのbinding

//emlist[例][ruby]{
require 'erb'
erb = ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test1 = "foo"
test2 = "bar"
puts erb.result
# test foo
# test bar
//...
<< 1 2 > >>