種類
- インスタンスメソッド (177)
- 文書 (88)
- 特異メソッド (24)
- 定数 (12)
- クラス (12)
クラス
- Binding (11)
- ERB (12)
- Module (36)
- NameError (10)
- Object (48)
- Thread (12)
- TracePoint (12)
-
WIN32OLE
_ TYPE (12) -
WIN32OLE
_ VARIABLE (60)
キーワード
- DATA (12)
-
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (5) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
-
WIN32OLE
_ VARIABLE (12) - binding (12)
-
class
_ variables (12) - constants (24)
-
initialize
_ copy (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
local
_ variables (21) - name (12)
- new (12)
-
ole
_ type (12) -
ole
_ type _ detail (12) -
ruby 1
. 8 . 3 feature (12) -
thread
_ variable _ set (12) -
to
_ s (12) - value (12)
- クラス/メソッドの定義 (12)
- プログラム・文・式 (12)
- 変数と定数 (12)
検索結果
先頭5件
-
WIN32OLE
_ TYPE # variables -> [WIN32OLE _ VARIABLE] (18113.0) -
型が持つ変数を取得します。
...知します。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
puts "#{v.name} = #{v.value}"
end
上記を実行すると以下の出力が得られます。
xlChart = -4109
xlDialogSheet = -4116... -
Module
# class _ variables(inherit = true) -> [Symbol] (6149.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module... -
Binding
# local _ variables -> [Symbol] (6125.0) -
ローカル変数の一覧を Symbol の配列で返します。
...カル変数の一覧を Symbol の配列で返します。
//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}
このメソッドは以下のコードと同様の動作をします。
//emlist[][ruby]{
binding.eval("local_variables")
//}... -
NameError
# local _ variables -> [Symbol] (6119.0) -
self が発生した時に定義されていたローカル変数名の一覧を返します。
...発生した時に定義されていたローカル変数名の一覧を返します。
内部での使用に限ります。
例:
def foo
begin
b = "bar"
c = 123
d
rescue NameError => err
p err.local_variables #=> [:b, :c, :err]
end
end
a = "buz"
foo... -
変数と定数 (3192.0)
-
変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio
...変数を参照した時の値はnilです。
===[a:class] クラス変数
//emlist[例][ruby]{
class Foo
@@foo = 1
def bar
puts @@foo
end
end
//}
@@で始まる変数はクラス変数です。クラス変数はクラス定義
の中で定義され、クラスの特異メソッド、......ル変数であるとみなすことができます。
//emlist[][ruby]{
class Foo
@@foo = 1
end
class Bar < Foo
p @@foo += 1 # => 2
end
class Baz < Bar
p @@foo += 1 # => 3
end
//}
モジュールで定義されたクラス変数(モジュール変数)は、そのモジ......したクラス間でも共有されます。
//emlist[][ruby]{
module Foo
@@foo = 1
end
class Bar
include Foo
p @@foo += 1 # => 2
end
class Baz
include Foo
p @@foo += 1 # => 3
end
//}
親クラスに、子クラスで既に定義されている同名のクラス変......したクラス間でも共有されます。
//emlist[][ruby]{
module Foo
@@foo = 1
end
class Bar
include Foo
p @@foo += 1 # => 2
end
class Baz
include Foo
p @@foo += 1 # => 3
end
//}
親クラスに、子クラスで既に定義されている同名のクラス変... -
クラス/メソッドの定義 (558.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...fined
===[a:class] クラス定義
//emlist[例][ruby]{
class Foo < Super
def test
# ...
end
# ...
end
//}
文法:
class 識別子 [`<' superclass ]
式..
end
文法:
class 識別子 [`<' superclass ]
式..
[rescue [erro......r_type,..] [=> evar] [then]
式..]..
[else
式..]
[ensure
式..]
end
クラスを定義します。クラス名はアルファベットの大文字で始まる識別子です。
rescue/ensure 節を指定し、例外処理ができ......には別名を付けることができません。
また、インタプリタに対して重要な意味のあるグローバル変数
(d:spec/variables#builtin_variable を参照)を再定義すると動作に
支障を来す場合があります。
alias 式は nil を返します。
====[a:u... -
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (90.0)
-
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or plus minus ast slash hat sq period comma langl rangl eq tilde dollar at under lbrarbra lbra2rbra2 lbra3rbra3 dq colon ac backslash semicolon
...ソッドを示すために使われます。
: xx ? yy : zz
d:spec/operator#cond。三項演算子とも呼ばれます。if xx then yy else zz end と同じ意味です。
: /xxx?/
正規表現の、量指定子(quantifiers)。直前の正規表現の 0 または 1 回の繰り返し。
===......子。d:spec/variables#const を参照。
: ::DateTime
定数のスコープ演算子で、トップレベルの定数であることを示す。Object クラスで
定義されている定数(トップレベルの定数と言う)を確実に参照するためには
d:spec/variables#const を......参照。
: xx ? yy : zz
条件演算子。三項演算子とも呼ばれます。if xx then yy else zz end と同じ意味です。
d:spec/operator#cond を参照。
: { a:"aaa", b:"bbb" }
ハッシュの新しい記法。以下と同じです。
//emlist{
{ :a => "aaa", :b => "bbb" }
//}... -
ruby 1
. 8 . 3 feature (84.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...た。
$ cat mthd_taint.rb
th = Thread.new{
$SAFE = 3
class Hoge
def foo
puts "safe level: #{$SAFE}"
end
end
}
th.join
p $SAFE
Hoge.new.foo
$ ruby-1.8.2 mthd_taint.rb
0
"safe level: 0"
$ ruby-1.8.3 mthd_ta......るバグを修正しました。
$ cat r.rb
p /[\c\\]/ =~ "\c\\"
p /\c\\/ =~ "\c\\"
$ ruby-1.8.2 r.rb
r.rb:1: premature end of regular expression: /[\c\\]/
r.rb:2: invalid regular expression; '\' can't be last character: /\c\\/
$ ruby-1.8.3 r.rb
0
0
=......rror を投げます。
$ ruby-1.8.2 -se 'puts global_variables.grep(/foo/)' -- --foo-bar
$-foo-bar
$ ruby-1.8.3 -se 'puts global_variables.grep(/foo/)' -- --foo-bar
$_foo_bar
$ ruby-1.8.3 -se 'puts global_variables.grep(/foo/)' -- --foo\@bar
-e: invalid name for glob... -
Object
:: DATA -> File (76.0) -
スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。
...スクリプトの __END__
プログラムの終り以降をアクセスする File オブジェクト。
d:spec/program#terminateも参照。
ソースファイルの __END__ 以降は解析・実行の対象にならないので
その部分にプログラムが利用するためのデータを......するための File オブジェクトを保持しています。
__END__ を含まないプログラムにおいては DATA は定義されません。
=== 注意
* DATA.rewind で移動する読みとり位置は __END__ 直後ではなく、
スクリプトファイルの先頭で......みこまれなかった場合や、
__END__ で終っていない場合には定義されません。
* Kernel.#require や Kernel.#load で
読み込まれたファイルの中であってもそのファイル (__FILE__, d:spec/variables#pseudo)
ではなく実行されたフ...