種類
- 文書 (40)
- 特異メソッド (24)
- インスタンスメソッド (16)
ライブラリ
- ビルトイン (40)
クラス
- Module (24)
- Refinement (4)
オブジェクト
- main (12)
キーワード
-
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 3
. 1 . 0 (4) - Ruby用語集 (12)
-
import
_ methods (4) -
ruby 1
. 6 feature (12) -
used
_ modules (12) - using (12)
検索結果
先頭5件
-
Module
# refine(klass) { . . . } -> Module (18153.0) -
引数 klass で指定したクラスまたはモジュールだけに対して、ブロックで指定した機能を提供で きるモジュールを定義します。定義した機能は Module#refine を使用せずに直 接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。 そのため、既存の機能を局所的に修正したい場合などに用いる事ができます。
...義した機能は Module#refine を使用せずに直
接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。
そのため、既存の機能を局所的に修正したい場合などに用いる事ができます。
refinements 機能の詳細に......ついては以下を参照してください。
* https://magazine.rubyist.net/articles/0041/0041-200Special-refinement.html
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html
定義した機能は main.using, Module#using を実行した場合のみ
有効になります。
@......機能を持つ無名のモジュールを返します。
//emlist[例][ruby]{
class C
def foo
puts "C#foo"
end
end
module M
refine C do
def foo
puts "C#foo in M"
end
end
end
x = C.new
x.foo # => "C#foo"
using M
x = C.new
x.foo # => "C#foo in M"
//}
@see main.using... -
Refinement
# import _ methods(*modules) -> self (3048.0) -
モジュールからメソッドをインポートします。
...ルからメソッドをインポートします。
Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。
メソッドをコピーするため、Rubyコードで定義され......level)
' ' * level + self
end
end
module M
refine String do
import_methods StrUtils
end
end
using M
p "foo".indent(3) # => " foo"
module M
refine String do
import_methods Enumerable
# Can't import method which is not defined with Ruby code: Enumerable#drop
end
end
//}... -
ruby 1
. 6 feature (306.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...ーになっていました。
((<ruby-dev:17155>))
open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3......トで 2 回シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))
trap(:TERM, "EXIT")
END{
puts "exit"
}
Thread.start { Thread.stop }
sleep
: 2002-04-17: Regexp#inspect
((<ruby-bugs-ja:PR#222>))
p %r{\/}......eError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-03-15) [i586-linux]
: 2002-03-13 ((<getopts>))
refine. ((<ruby-dev:16193>)), ((<ruby-dev:16213>))
: 2002-03-11 正規表現中の 8 進コード
正規表現中の \nnn による 8 進記法で... -
NEWS for Ruby 3
. 1 . 0 (48.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ッドに渡されるだけの場合は、ブロックの引数を無名にできるようになりました。 11256
//emlist{
def foo(&)
bar(&)
end
//}
* ピン演算子に式を書けるようになりました。 17411
//emlist{
Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3......に持つ配列(シングルトンクラスを含まない)を返します。
//emlist[Class#subclasses][ruby]{
class A; end
class B < A; end
class C < B; end
class D < A; end
A.subclasses #=> [D, B]
B.subclasses #=> [C]
C.subclasses #=> []
//}
* Enumerable
* 新規メソッド......17827
* コピーコルーチンをpthread実装に置き換えました。 18015
* Refinement
* Module#refineで作成されたモジュールを表す新しいクラス。includeとprependは非推奨になり、代わりにimport_methodsが追加されました。
== 標準添付... -
Module
. used _ modules -> [Module] (36.0) -
現在のスコープで using されているすべてのモジュールを配列で返します。 配列内のモジュールの順番は未定義です。
...ープで using されているすべてのモジュールを配列で返します。
配列内のモジュールの順番は未定義です。
//emlist[例][ruby]{
module A
refine Object do
end
end
module B
refine Object do
end
end
using A
using B
p Module.used_modules
#=> [B, A]
//}... -
NEWS for Ruby 2
. 1 . 0 (36.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ence としてサポートしました??
* 拡張: IO#seek 第2引数としてシンボルを受け付けるようになりました (:CUR, :END, :SET, :DATA, :HOLE)
* 拡張: IO#read_nonblock シンボルを返すためにキーワード引数 `exception: false` を受け付けるよう......なりました
* Kernel
* 追加: Kernel#singleton_method(Object#singleton_method)
* Module
* 追加: Module#using, which activates refinements of the specified module only
in the current class or module definition.
* 追加: Module#singleton_class? レシーバーが特異......通常のクラスやモジュールであれば false を返します。
* 拡張: Module#refine はもはや実験的な機能でなくなりました
* 拡張: Module#include と Module#prepend はパブリックメソッドになりました
* Mutex
* Mutex#owned? はもはや実... -
main
. using(module) -> self (30.0) -
引数で指定したモジュールで定義された拡張を有効にします。
...ntax/refinements_rdoc.html#label-Scope
@param module 有効にするモジュールを指定します。
//emlist[例][ruby]{
module Sloth
refine String do
def downcase
self
end
end
end
"ABC".downcase # => "abc"
using Sloth
"ABC".downcase # => "ABC"
//}
@see Module#refine, Mo... -
Ruby用語集 (24.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...た静的型付け言語であり、処理系はコンパイラーである。
https://ja.crystal-lang.org/
: CSI 方式
CSI は Code Set Independent の頭字語。
プログラミング言語の処理系が文字列を扱う際のエンコーディングに関する方針の一つ。
与......し、合わせてドキュメントの HTML を生成する。
参照:rdoc
: refinement
既存のクラスやモジュールを特定のスコープでのみ改変する仕組み。
参照:Module#refine、Module#using、main.using
: Ruby Central
Rubyのサポートと世界の Ruby......序関係を表す
演算子 <=> の俗称。
: 埋め込みドキュメント
: embedded document
ソースコード中の =begin 行から =end 行まで。コメントとみなされ実行されない。
その名の通り、この部分にコードのドキュメントを記述するこ...