種類
- インスタンスメソッド (120)
- 文書 (65)
- モジュール関数 (36)
- 特異メソッド (12)
- クラス (12)
クラス
- ERB (12)
- Object (12)
-
WIN32OLE
_ TYPE (12) -
WIN32OLE
_ VARIABLE (96)
モジュール
- Kernel (36)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 3
. 0 . 0 (5) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
-
WIN32OLE
_ VARIABLE (12) -
initialize
_ copy (12) - name (12)
- new (12)
-
ole
_ type (12) -
ole
_ type _ detail (12) -
ruby 1
. 8 . 3 feature (12) -
to
_ s (12) -
trace
_ var (36) - value (12)
-
variable
_ kind (12) - varkind (12)
- visible? (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
xlDialogSh... -
変数と定数 (3006.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
//}
@@で始まる変数はクラス変数です。クラス変数はクラス定義
の中で定義され、クラスの特異... -
クラス/メソッドの定義 (102.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...結果
として他の言語における「関数」のように使えます。
//emlist[例][ruby]{
def hello # 引数のないメソッド。
puts "Hello, world!"
end
def foo(a, b) # 引数のあるメソッド。括弧を省いてdef foo a, bとも
a + 3 * b
end
//}
メソッド名......t[例][ruby]{
def foo(x, *xs)
puts "#{x} : #{xs.inspect}" # Object#inspect は p のような詳細な内部表示
end
foo(1) #=> 1 : []
foo(1, 2) #=> 1 : [2]
foo(1, 2, 3) #=> 1 : [2, 3]
def bar(x, *) # 残りの引数を単に無視したいとき
puts "#{x}"
end
bar(1) #=......には別名を付けることができません。
また、インタプリタに対して重要な意味のあるグローバル変数
(d:spec/variables#builtin_variable を参照)を再定義すると動作に
支障を来す場合があります。
alias 式は nil を返します。
====[a:u... -
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (72.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
...一種。d:spec/literal#percent。ダブルクォート文字列で %Q!STRING! と同じ。
//emlist{
p %!nomad! #=> "nomad"
//}
: % ruby -e "puts 'Hello'"
コマンドラインへの入力を示す。rubyスクリプト上で入力を行うには `command` や system(command) などと書く......子。d:spec/variables#const を参照。
: ::DateTime
定数のスコープ演算子で、トップレベルの定数であることを示す。Object クラスで
定義されている定数(トップレベルの定数と言う)を確実に参照するためには
d:spec/variables#const を......ばいけません。
===[a:dollar] $
: $xxx
グローバル変数。d:spec/variables#globalを参照。
: $_ や $! など ・・$<1文字の数字、記号>
特殊変数(組み込み変数)。d:spec/variables#builtin を参照。
: /xx$/
正規表現で行末。文字列の末尾や改... -
ruby 1
. 8 . 3 feature (54.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
"sa......((<ruby-talk:146776>)) ((<ruby-talk:146894>))
$ cat test_dlg.rb
foo = Object.new
foo2 = SimpleDelegator.new(foo)
def foo.bar
puts "bar"
end
foo2.bar
$ ruby-1.8.2 -r delegate test_dlg.rb
test_dlg.rb:6: undefined method `bar' for #<Object:0x4021b0a0> (N......NameError を投げます。
$ 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 fo... -
Object
# initialize _ copy(obj) -> object (36.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...def check(obj)
puts "instance variables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
obj.taint
check Object.new.send(:initialize_copy, obj)
#=> instance variables: #<Object:0x40......n methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# tainted?: true
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=1>
# tainted?: true
#... -
WIN32OLE
_ VARIABLE (36.0) -
OLEオートメーションの変数情報をRubyで参照するためのクラスです。
...は、WIN32OLE_TYPE#variablesメソッ
ドを利用して取得します。
=== サンプルコード
require 'win32ole'
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
variables = tobj.variables
variables.each do |variable|
puts "#{variable.name}=#......{variable.value}"
end
実行結果は以下となります。
xlChart=-4109
xlDialogSheet=-4116
xlExcel4IntlMacroSheet=4
xlExcel4MacroSheet=3
xlWorksheet=-4167
@see WIN32OLE_TYPE#variables... -
Object
# initialize _ copy(obj) -> object (30.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
check Object.new.send(:initialize_copy, obj)
#=> instance variables: #<Object:0x4019c9d4>
# sin......gleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=1>
# singleton methods: :bar
//}
@see Object#initia... -
WIN32OLE
_ VARIABLE # name -> String (24.0) -
変数名を取得します。
...変数名を取得します。
@return 変数名を文字列で返します。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
variables = tobj.variables
variables.each do |variable|
puts "#{variable.name}" # => xlChart, xlDialogSheet, ...
end... -
WIN32OLE
_ VARIABLE # ole _ type -> String (24.0) -
変数の型を取得します。
...字列
を返します。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
variables = tobj.variables
variables.each do |variable|
puts "#{variable.ole_type} #{variable.name}"
end
OLEオートメーションの型名は、対応するWIN32OLE::VARI...