るりまサーチ

最速Rubyリファレンスマニュアル検索!
990件ヒット [1-100件を表示] (0.112秒)
トップページ > クエリ:l[x] > クエリ:define[x]

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l
  5. $-l kernel

ライブラリ

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Data.define(*args) {|subclass| block } -> Class (18344.0)

Data クラスに新しいサブクラスを作って、それを返します。

...ドが定義されています。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}

メンバの値を書き換えることはできません。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)...
...//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetch...
...er = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}

@param args 値オブ...

Data.define(*args) -> Class (18244.0)

Data クラスに新しいサブクラスを作って、それを返します。

...ドが定義されています。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}

メンバの値を書き換えることはできません。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)...
...//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def fetch(url)
fetch...
...er = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}

@param args 値オブ...

Rake::PackageTask#define -> self (18201.0)

タスクを定義します。

タスクを定義します。

@raise RuntimeError バージョン情報をセットしていない場合に発生します。
初期化時に :noversion が指定されている場合は発生しません。

Rake::RDocTask#define -> self (18201.0)

タスクを定義します。

タスクを定義します。

Rake::TestTask#define -> self (18201.0)

タスクを定義します。

タスクを定義します。

絞り込み条件を変える

Module#class_variable_defined?(name) -> bool (15200.0)

name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。

...name Symbol か String を指定します。

//emlist[例][ruby]{
class Fred
@@foo = 99
end
Fred.class_variable_defined?(:@@foo) #=> true
Fred.class_variable_defined?(:@@bar) #=> false
Fred.class_variable_defined?('@@foo') #=> true
Fred.class_variable_defined?('@@bar') #=> false
//}...

VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super) (12400.0)

super のサブクラスとして新しい Ruby クラスを、outer の定数として定義し て返します。

...属するクラス

@param name クラス名

@param super 継承元のクラス。NULL を指定した場合は Object クラス

@raise TypeError 引数 name と同じ名前の定数が既に存在し、それが
Class オブジェクトではない場合に発生します。...
...クラス

@param name クラス名

@param super 継承元のクラス。NULL を指定した場合は Object クラス

@raise TypeError 引数 name と同じ名前の定数が既に存在し、それが
Class オブジェクトではない場合に発生します。

@raise TypeE...

static VALUE define_final(int argc, VALUE *argv, VALUE os) (12400.0)

static VALUE undefine_final(VALUE os, VALUE obj) (12400.0)

void rb_define_module_function(VALUE module, const char *name, VALUE (*func)(), int argc) (12316.0)

モジュール module にモジュール関数 name を定義します。 func と argc は rb_define_method と同じです。

...モジュール module にモジュール関数 name を定義します。
func と argc は rb_define_method と同じです。...

絞り込み条件を変える

TracePoint#defined_class -> Class | module (12300.0)

メソッドを定義したクラスかモジュールを返します。

.../emlist[例][ruby]{
class C; def foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => C
end.enable do
C.new.foo
end
//}

メソッドがモジュールで定義されていた場合も(include に関係なく)モジュー
ルを返します。

//emlist[例][ruby]{
module...
...M; def foo; end; end
class C; include M; end;
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => M
end.enable do
C.new.foo
end
//}

[注意] 特異メソッドを実行した場合は TracePoint#defined_class は特異クラ
スを返します。また、Kernel.#set_trace_func の 6...
...は特異クラスではなく元のクラスを返します。

//emlist[例][ruby]{
class C; def self.foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => #<Class:C>
end.enable do
C.foo
end
//}

Kernel.#set_trace_func と TracePoint の上記の差分に注意して
...
<< 1 2 3 ... > >>