種類
ライブラリ
- ビルトイン (516)
- csv (22)
- digest (11)
- forwardable (55)
- json (11)
-
minitest
/ spec (1) -
minitest
/ unit (2) - openssl (11)
- pp (11)
- prime (77)
-
rdoc
/ context (11) -
rubygems
/ command _ manager (11) - singleton (22)
- syslog (11)
-
webrick
/ httpservlet / abstract (11) -
webrick
/ httpservlet / prochandler (11) - zlib (11)
クラス
- BasicObject (44)
- CSV (22)
-
Gem
:: CommandManager (11) -
JSON
:: Parser (11) - Module (143)
- Object (199)
- Prime (66)
-
RDoc
:: Context (11) - UnboundMethod (76)
-
WEBrick
:: HTTPServlet :: AbstractServlet (11) -
WEBrick
:: HTTPServlet :: ProcHandler (11)
モジュール
- Enumerable (11)
- Forwardable (44)
- Kernel (33)
-
MiniTest
:: Assertions (2) - Singleton (11)
- Syslog (11)
オブジェクト
- main (22)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - === (11)
- Digest (11)
- Instance (11)
- Marshal フォーマット (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - Prime (11)
- Ruby用語集 (11)
- SingleForwardable (11)
- Singleton (11)
- TYPES (11)
- ZStream (11)
- arity (11)
-
assert
_ instance _ of (1) -
assert
_ kind _ of (1) - bind (11)
-
bind
_ call (10) -
class
_ eval (11) -
class
_ variables (11) - constants (11)
-
def
_ delegator (11) -
def
_ instance _ delegator (11) -
def
_ instance _ delegators (11) -
define
_ method (44) - each (22)
- eval (11)
-
get
_ instance (22) -
global
_ variables (11) - grep (11)
-
initialize
_ copy (11) -
ins
_ methods _ i (11) -
ins
_ methods _ priv _ i (11) -
ins
_ methods _ prot _ i (11) - inspect (11)
-
instance
_ delegate (11) -
instance
_ eval (22) -
instance
_ exec (11) -
instance
_ method (11) -
instance
_ methods (11) -
instance
_ of? (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) -
int
_ from _ prime _ division (11) - irb (11)
-
irb
/ completion (11) -
is
_ a? (11) -
kind
_ of? (11) -
local
_ variables (11) - methods (11)
-
module
_ eval (11) -
must
_ be _ instance _ of (1) - new (11)
-
original
_ name (11) -
pretty
_ print _ instance _ variables (11) - prime? (11)
-
prime
_ division (11) -
private
_ instance _ methods (11) -
private
_ methods (11) -
protected
_ instance _ methods (11) -
protected
_ methods (11) -
public
_ instance _ method (11) -
public
_ instance _ methods (11) -
public
_ method (11) -
public
_ methods (11) -
rb
_ class _ allocate _ instance (11) -
rb
_ class _ instance _ methods (11) -
rb
_ class _ new _ instance (11) -
rb
_ class _ private _ instance _ methods (11) -
rb
_ class _ protected _ instance _ methods (11) -
rb
_ is _ instance _ id (11) -
rb
_ obj _ instance _ eval (11) -
rb
_ obj _ instance _ variables (11) -
rb
_ obj _ is _ instance _ of (11) -
rb
_ obj _ remove _ instance _ variable (11) -
remove
_ class _ variable (11) -
remove
_ instance _ variable (11) -
respond
_ to? (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) -
singleton
_ method (11) -
singleton
_ method _ undefined (11) -
source
_ location (11) -
specific
_ eval (11) -
to
_ s (11) - 変数と定数 (11)
検索結果
先頭5件
-
Module
# class _ eval(expr , fname = "(eval)" , lineno = 1) -> object (106.0) -
モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。
...とができます。
@param lineno 文字列を指定します。行番号 lineno から文字列 expr が書かれているかのように実行されます。
スタックトレースの表示などを差し替えることができます。
//emlist[例][ruby]{
class C
end
a = 1
C.......class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end
}
p C.new.m #=> [:m, 1]
//}
@see BasicObject#instance_eval, Module.new, Kernel.#eval... -
Module
# constants(inherit = true) -> [Symbol] (106.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...そのモジュール(またはクラス)で定義されている定数名の配列を返します。
inherit に真を指定すると
スーパークラスやインクルードしているモジュールの定数も含みます。
Object のサブクラスの場合、Objectやそのスーパー......am inherit true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_......variables, Module#class_variables
//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.constants
class Foo
FOO = 1
end
class Bar
BAR = 1
# Bar は BAR を含む
p constants... -
Module
# module _ eval(expr , fname = "(eval)" , lineno = 1) -> object (106.0) -
モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。
...とができます。
@param lineno 文字列を指定します。行番号 lineno から文字列 expr が書かれているかのように実行されます。
スタックトレースの表示などを差し替えることができます。
//emlist[例][ruby]{
class C
end
a = 1
C.......class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end
}
p C.new.m #=> [:m, 1]
//}
@see BasicObject#instance_eval, Module.new, Kernel.#eval... -
Object
# respond _ to?(name , include _ all = false) -> bool (106.0) -
オブジェクトがメソッド name を持つとき真を返します。
...クトが メソッド name に応答できることをいいます。
Windows での Process.fork や GNU/Linux での File.lchmod の
ような NotImplementedError が発生する場合は false を返します。
※ NotImplementedError が発生する場合に false を返すのは
Rubyの組......otImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字列で指定するメソッド名です。
@param include_all priva......なります。
//emlist[][ruby]{
class F
def hello
"Bonjour"
end
end
class D
private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]
list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour
list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hello, tru... -
Ruby用語集 (76.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...Ruby用語集
A B C D E F G I J M N O R S Y
a ka sa ta na ha ma ya ra wa
=== 記号・数字
: %記法
: % notation
「%」記号で始まる多種多様なリテラル記法の総称。
参照:d:spec/literal#percent
: 0 オリジン
: zero-ba......sed
番号が 0 から始まること。
例えば、
Array や Vector、Matrix などの要素の番号、
String における文字の位置、
といったものは 0 オリジンである。
: 1 オリジン
: one-based
番号が 1 から始まること。
例えば、
エラ......る。
一方、Fiber を使って繰り返し処理を行うオブジェクトを作る
ことができるが、こちらは一回のメソッド呼び出しで一回分の反復を行う
ので外部イテレーターに分類される。
: インスタンス
: instance
あるクラス... -
NEWS for Ruby 2
. 1 . 0 (36.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 2.0.0 以降の変更
=== 言語仕様の変更
* キーワード引数のデフォルト値が省略可......尾に'r','i','ri'という接尾辞を付けられるようになりました
//emlist{
# r を付けると有理数になる
42r # => Rational(42, 1)
3.14 # => 3.14.rationalize
6.022e+23r # 指数形式と一緒には使えない
# i を付けると虚数単位 i を掛けた......を呼び出すと警告するようになりました。
* IO
* 非互換: IO.open は外部エンコーディングが ASCII-8BIT のとき内部エンコーディングを無視します。
* Kernel.#eval, Kernel.#instance_eval, Module#module_eval
元の環境のスコープ情報... -
NEWS for Ruby 2
. 0 . 0 (30.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
== 1.9.3 以降の変更
=== 言語仕様の変更
* キーワード引数を追加しました
* %i, %I をシンボルの配列作成のために追加しました。(%w, %W に......コーディングを US-ASCII から UTF-8 に変更しました
* '_' で始まる使用されていない変数は警告しなくなりました
=== 組み込みクラスの更新
* ARGF.class
* 追加: ARGF.class#codepoints, ARGF.class#each_codepoint
IO にある同名のメソ......ead#thread_variables スレッドローカルな変数の名前のリストを取得します
* 追加: Thread#thread_variable? 与えられた名前がスレッドローカルな変数であるかどうか返します
* 追加: Thread.handle_interrupt as well as instance and singleton metho... -
NEWS for Ruby 3
. 0 . 0 (30.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs
accepting......single rest argument and no keywords.
16166
//emlist[][ruby]{
pr = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]
pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leadin......tion shows the help message via the pager designated by the value.
16754
=== `--backtrace-limit` option
The `--backtrace-limit` option limits the maximum length of a backtrace.
8661
== Core classes updates
Outstanding ones only.
* Array
* The following methods now return Array instances i... -
NEWS for Ruby 2
. 7 . 0 (24.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ルか bugs.ruby-lang.org の issue を参照してください。
== 2.6.0 以降の変更
=== 言語仕様の変更
==== パターンマッチ
* パターンマッチが実験的機能として導入されました。 14912
//emlist[][ruby]{
case [0, [1, 2, 3]]
in [a, [b, *c]]
p a #=> 0......nd
//}
//emlist[][ruby]{
case {a: 0, b: 1}
in {a: 0, x: 1}
:unreachable
in {a: 0, b: var}
p var #=> 1
end
//}
//emlist[][ruby]{
case -1
in 0 then :unreachable
in 1 then :unreachable
end #=> NoMatchingPatternError
//}
//emlist{
json = <<END
{
"name": "Alice",
"age": 30,
"children": [{ "n......クトは untainted 扱いです。)
verbose モードでは警告が表示されます。
この警告は Ruby 3.0 では verbose モードでなくても表示され、Ruby 3.2 で削除される
予定です。 16131
* Object#methodとModule#instance_methodがrefinementsを考慮... -
Object
# ===(other) -> bool (18.0) -
case 式で使用されるメソッドです。d:spec/control#case も参照してください。
...トです。
//emlist[][ruby]{
age = 12
# (0..2).===(12), (3..6).===(12), ... が実行される
result =
case age
when 0 .. 2
"baby"
when 3 .. 6
"little child"
when 7 .. 12
"child"
when 13 .. 18
"youth"
else
"adult"
end
puts result #=> "child"
def check arg
ca....../ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end
puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's world>...