るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

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

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

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

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

signature で関数の名前とシネグチャを指定します。例えば
"int compare(void*, void*)" のように指定します。

opts には :stdcall もしくは :cdecl を渡すことができ、
呼出規約を明示することができます。

@return インポートし...
...Function オブジェクトを返します。

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


require 'fiddle/import'

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

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

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

...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>


# モジュールのインスタンスメソッドの UnboundMethod の場...

UnboundMethod#bind_call(recv, *args) -> object (9243.0)

self を recv に bind して args を引数として呼び出します。

...self を recv に bind して args を引数として呼び出します。

self.bind(recv).call(*args) と同じ意味です。

//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}

@see UnboundMethod#bind, Method#call...

UnboundMethod#bind_call(recv, *args) { ... } -> object (9243.0)

self を recv に bind して args を引数として呼び出します。

...self を recv に bind して args を引数として呼び出します。

self.bind(recv).call(*args) と同じ意味です。

//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}

@see UnboundMethod#bind, Method#call...

Method#unbind -> UnboundMethod (9213.0)

self のレシーバとの関連を取り除いた UnboundMethod オブ ジェクトを生成して返します。

...除いた UnboundMethod オブ
ジェクトを生成して返します。

//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
unbound_method = m.unbind # => #<UnboundMethod: Foo#foo>
unbound_method.bind(Foo.new) # => #<Method: Foo#foo>
//}...

絞り込み条件を変える

TracePoint#binding -> Binding (9207.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
t
race.enable
foo 1
//}...

TracePoint#binding -> Binding | nil (9207.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...れた Binding オブジェクトを返します。

C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:...
...call) do |tp|
p tp.binding.local_variables # => [:ret]
end
t
race.enable
foo 1
//}...

Binding#local_variable_set(symbol, obj) (9149.0)

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

.../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.loca...
...l_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}

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

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

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

Binding#source_location -> [String, Integer] (9123.0)

self の Ruby のソースファイル名と行番号を返します。

...self の Ruby のソースファイル名と行番号を返します。

d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。

//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}...

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

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

...

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

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

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

@see Binding#local_variable_set, Binding#local_var...

絞り込み条件を変える

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

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

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

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

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