1115件ヒット
[1-100件を表示]
(0.027秒)
別のキーワード
ライブラリ
- ビルトイン (555)
- delegate (12)
- erb (24)
- forwardable (48)
- json (24)
- logger (1)
- monitor (12)
- observer (12)
- openssl (24)
- psych (12)
-
rexml
/ document (24) - thread (2)
- tracer (24)
-
webrick
/ httpauth / digestauth (12) - win32ole (36)
クラス
- BasicObject (84)
- Class (48)
- Data (18)
- ERB (24)
- File (12)
- Module (24)
- Object (120)
- Proc (19)
-
REXML
:: Child (12) -
REXML
:: Parent (12) - Struct (4)
- Thread (24)
-
Thread
:: Backtrace :: Location (48) - Tracer (24)
- WIN32OLE (12)
-
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ TYPE (12)
モジュール
- Enumerable (96)
- Forwardable (48)
- JSON (12)
-
JSON
:: Generator :: GeneratorMethods :: Object (12) - Kernel (12)
- ObjectSpace (36)
キーワード
- ! (12)
- != (12)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - == (12)
- Application (1)
- BasicObject (12)
- Cipher (12)
- ConditionVariable (12)
- DelegateClass (12)
- DigestAuth (12)
- Location (12)
- Marshal フォーマット (12)
- MonitorMixin (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Observable (12)
- RSA (12)
- Ruby用語集 (12)
- [] (7)
-
_ dump (12) -
absolute
_ path (12) - allocate (12)
-
base
_ label (12) -
cgi
/ session (12) -
create
_ id (12) -
def
_ class (12) -
def
_ delegator (12) -
def
_ instance _ delegator (12) -
default
_ event _ sources (12) - define (6)
-
define
_ finalizer (24) - delegate (12)
-
drb
/ extservm (12) -
drb
/ gw (12) - fork (12)
- handler= (12)
-
initialize
_ copy (12) - inspect (24)
-
instance
_ delegate (12) -
instance
_ eval (24) -
instance
_ exec (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
irb
/ completion (12) - logger (12)
-
marshal
_ dump (12) - max (48)
-
method
_ missing (12) - min (48)
-
ole
_ activex _ initialize (12) - path (12)
- rdoc (12)
-
rdoc
/ generator / json _ index (12) -
rexml
/ parsers / streamparser (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
set
_ get _ line _ procs (24) -
singleton
_ method (12) - start (12)
-
to
_ json (12) -
to
_ s (24) - tsort (12)
-
undefine
_ finalizer (12) - yaml (12)
-
yaml
_ tag (12) - クラス/メソッドの定義 (12)
- セキュリティモデル (12)
- パターンマッチ (12)
- 演算子式 (12)
検索結果
先頭5件
-
Object
# initialize(*args , &block) -> object (18173.0) -
ユーザ定義クラスのオブジェクト初期化メソッド。
...このメソッドは Class#new から新しく生成されたオブ
ジェクトの初期化のために呼び出されます。他の言語のコンストラクタに相当します。
デフォルトの動作ではなにもしません。
initialize には
Class#new に与えられた引数が......。
initialize という名前のメソッドは自動的に private に設定され
ます。
@param args 初期化時の引数です。
@param block 初期化時のブロック引数です。必須ではありません。
//emlist[][ruby]{
class Foo
def initialize name
puts "initialize Fo......o"
@name = name
end
end
class Bar < Foo
def initialize name, pass
puts "initialize Bar"
super name
@pass = pass
end
end
it = Bar.new('myname','0500')
p it
#=> initialize Bar
# initialize Foo
# #<Bar:0x2b68f08 @name="myname", @pass="0500">
//}
@see Class#new... -
Class
# new(*args , &block) -> object (18153.0) -
自身のインスタンスを生成して返します。 このメソッドの引数はブロック引数も含め Object#initialize に渡されます。
...ク引数も含め Object#initialize に渡されます。
new は Class#allocate でインスタンスを生成し、
Object#initialize で初期化を行います。
@param args Object#initialize に渡される引数を指定します。
@param block Object#initialize に渡されるブロッ......クを指定します。
//emlist[例][ruby]{
# Class クラスのインスタンス、C クラスを生成
C = Class.new # => C
# Class クラスのインスタンス、C クラスのインスタンスを生成
C.new # => #<C:0x00005623f8b4e458>
//}... -
Class
. new(superclass = Object) -> Class (18150.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name......s.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}
この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定します。
//emlist[例][ruby]{
k = Class.new{......|c|
def initialize
p "in initialize"
end
def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.hoge #=> "hoge hoge hoge"
//}... -
Class
. new(superclass = Object) {|klass| . . . } -> Class (18150.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name......s.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}
この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定します。
//emlist[例][ruby]{
k = Class.new{......|c|
def initialize
p "in initialize"
end
def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.hoge #=> "hoge hoge hoge"
//}... -
Proc
. new -> Proc (18138.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...クを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生しま......ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}
これは以下と同じです。
//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#......が発生します。
//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期... -
Proc
. new { . . . } -> Proc (18138.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...クを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生しま......ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}
これは以下と同じです。
//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#......が発生します。
//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期......ときに発生します。
//emlist[][ruby]{
pr = Proc.new {|arg| p arg }
pr.call(1) # => 1
//}
//emlist[][ruby]{
Proc.new # => -e:1:in `new': tried to create Proc object without a block (ArgumentError)
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクトの初期化... -
ERB
. new(str , safe _ level=NOT _ GIVEN , trim _ mode=NOT _ GIVEN , eoutvar=NOT _ GIVEN , trim _ mode: nil , eoutvar: & # 39; _ erbout& # 39;) -> ERB (18125.0) -
eRubyスクリプト から ERB オブジェクトを生成して返します。
...:cost => 9.95 }
attr_reader :product, :price
def initialize( product = "", price = "" )
@product = product
@price = price
end
def build
b = binding
# create and run templates, filling member data variables
ERB.new(<<~'END_PRODUCT', eoutvar: "@product").result b......<%= PRODUCT[:desc] %>
END_PRODUCT
ERB.new(<<~'END_PRICE', eoutvar: "@price").result b
<%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
<%= PRODUCT[:desc] %>
END_PRICE
end
end
# setup template data
listings = Listings.new
listings.build
puts listings.product + "\n" + li... -
ERB
. new(str , safe _ level=nil , trim _ mode=nil , eoutvar=& # 39; _ erbout& # 39;) -> ERB (18125.0) -
eRubyスクリプト から ERB オブジェクトを生成して返します。
...:cost => 9.95 }
attr_reader :product, :price
def initialize( product = "", price = "" )
@product = product
@price = price
end
def build
b = binding
# create and run templates, filling member data variables
ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), 0, "", "@product").......PRODUCT[:desc] %>
END_PRODUCT
ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), 0, "", "@price").result b
<%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
<%= PRODUCT[:desc] %>
END_PRICE
end
end
# setup template data
listings = Listings.new
listings.build
puts listings.product + "\... -
ERB
. new(str , trim _ mode: nil , eoutvar: & # 39; _ erbout& # 39;) -> ERB (18125.0) -
eRubyスクリプト から ERB オブジェクトを生成して返します。
...:cost => 9.95 }
attr_reader :product, :price
def initialize( product = "", price = "" )
@product = product
@price = price
end
def build
b = binding
# create and run templates, filling member data variables
ERB.new(<<~'END_PRODUCT', eoutvar: "@product").result b......<%= PRODUCT[:desc] %>
END_PRODUCT
ERB.new(<<~'END_PRICE', eoutvar: "@price").result b
<%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
<%= PRODUCT[:desc] %>
END_PRICE
end
end
# setup template data
listings = Listings.new
listings.build
puts listings.product + "\n" + li... -
Module
. new -> Module (18120.0) -
名前の付いていないモジュールを新しく生成して返します。
...ルのコンテキストでブロックを実行します。
//emlist[例][ruby]{
mod = Module.new
mod.module_eval {|m|
# ...
}
mod
//}
と同じです。
ブロックの実行は Module#initialize が行います。
ブロックを与えた場合も生成したモジュールを返します。......。
モジュールの名前は、
そのモジュールが代入されている定数名のいずれかです。
//emlist[例][ruby]{
m = Module.new
p m # => #<Module 0lx40198a54>
p m.name # => nil # まだ名前は未定
Foo = m
# m.name # ここで m.name を呼... -
Module
. new {|mod| . . . } -> Module (18120.0) -
名前の付いていないモジュールを新しく生成して返します。
...ルのコンテキストでブロックを実行します。
//emlist[例][ruby]{
mod = Module.new
mod.module_eval {|m|
# ...
}
mod
//}
と同じです。
ブロックの実行は Module#initialize が行います。
ブロックを与えた場合も生成したモジュールを返します。......。
モジュールの名前は、
そのモジュールが代入されている定数名のいずれかです。
//emlist[例][ruby]{
m = Module.new
p m # => #<Module 0lx40198a54>
p m.name # => nil # まだ名前は未定
Foo = m
# m.name # ここで m.name を呼...