クラス
- Array (4)
- File (12)
- Range (12)
- Struct (24)
- Thread (12)
- WIN32OLE (24)
-
WIN32OLE
_ TYPE (12) -
WIN32OLE
_ VARIABLE (12)
モジュール
- Kernel (12)
-
Net
:: HTTPHeader (36)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Parser (12)
-
WIN32OLE
_ VARIABLE (12) - [] (12)
-
_ getproperty (12) -
_ setproperty (12) - each (36)
-
each
_ header (12) -
each
_ value (12) - flock (12)
-
net
/ http (12) -
net
/ imap (12) - new (12)
-
rb
_ protect (12) - rss (12)
-
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) - throw (12)
-
to
_ csv (4) - variables (12)
- クラス/メソッドの定義 (12)
- パターンマッチ (12)
検索結果
先頭5件
-
WIN32OLE
_ VARIABLE # value -> object | nil (18119.0) -
変数の値を取得します。
...変数の値を取得します。
変数情報によってはenum値のように定数値を持つものがあります。valueメソッ
ドはこのような定数値を返します。
@return この変数が持つ定数値。値を持たない場合はnilを返します。
tobj = WIN32OLE_T......YPE.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
xlExcel4MacroShee... -
Net
:: HTTPHeader # each _ value {|value| . . . . } -> () (6226.0) -
保持しているヘッダの値をブロックに渡し、呼びだします。
...れる文字列は ", " で連結したものです。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_value { |value| puts value }
# => gzip;q=1.0,deflate;q=0.6,identity;q=0.3
# => */*
# => Ruby
//}... -
VALUE rb
_ protect(VALUE (*proc)() , VALUE data , int *state) (306.0) -
初出: 4064
...初出: 4064
proc(data) を評価中のあらゆる大域脱出(例外を含む)を捕捉します。
val = rb_protect(func, arg, &status);
if (status != 0) {
puts("大域脱出が起きた");
rb_jump_tag(status);
}... -
クラス/メソッドの定義 (132.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) #=......# -obj
# 要素代入
def foo=(value); end # obj.foo = value
# [] と []=
def [](key); end # obj[key]
def []=(key, value); end # obj[key] = value
def []=(key, key2, value); end # obj[key, key2] = value
# バッククォート記法
def `(arg); e... -
ruby 1
. 8 . 4 feature (120.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...ns invalid symbol representations:
puts :"!".inspect
puts :"=".inspect
puts :"0".inspect
puts :"$1".inspect
puts :"@1".inspect
puts :"@@1".inspect
puts :"@".inspect
puts :"@@".inspect
# => r......"
:"@"
:"@@"
3) Symbol#inspect sometimes returns suboptimal symbol representations:
puts :foo!.inspect
puts :bar?.inspect
# => ruby 1.8.3 (2005-09-21) [i686-linux]
:"foo!"
:"bar?"......xt/tk/lib/tk/scale.rb,
# ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tk/text.rb,
# ext/tk/lib/tk/toplevel.rb: improve conversion of option values.
#
# * ext/tk/lib/tkextlib/*: ditto.
#
ウィジェットオブジェクトの属性参照をした場合に属性値として返す... -
Kernel
. # throw(tag , value = nil) -> () (119.0) -
Kernel.#catchとの組み合わせで大域脱出を行います。 throw は同じ tag を指定した catch のブロックの終わりまでジャンプします。
...Object#object_id が同じであるという意味です。
@param tag catch の引数に対応する任意のオブジェクトです。
@param value catch の戻り値になります。
@raise ArgumentError 同じ tag で待っている catch が存在しない場合に発生します。
//emli......st[例][ruby]{
def foo
throw :exit, 25
end
ret = catch(:exit) do
begin
foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=> ensure
# 25
//}
@see Kernel.#catch......Object#object_id が同じであるという意味です。
@param tag catch の引数に対応する任意のオブジェクトです。
@param value catch の戻り値になります。
@raise UncaughtThrowError 同じ tag で待っている catch が存在しない場合に発生します。
/....../emlist[例][ruby]{
def foo
throw :exit, 25
end
ret = catch(:exit) do
begin
foo
some_process() # 絶対に実行されない
10
ensure
puts "ensure"
end
end
puts ret
#=> ensure
# 25
//}
@see Kernel.#catch... -
Struct
# each {|value| . . . } -> self (107.0) -
構造体の各メンバに対して繰り返します。
...ct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.each {|x| puts(x) }
# => Joe Smith
# 123 Maple, Anytown NC
# 12345
//}... -
rss (78.0)
-
RSS を扱うためのライブラリです。
...df:about属性の
値を指定することもできます。
rss = RSS::Parser.parse(rss_source)
rss.channel = RSS::RDF::Channel.new(rdf_about_value)
属性値を設定する場合も同様です。
rss = RSS::Parser.parse(rss_source)
rss.channel.about = "http://cozmixng.www.cozmixng.org/......て
Array#<<やArray#[]=などを用いて要素を設定します.
rss = RSS::Parser.parse(rss_source)
item = RSS::RDF::Item.new(rdf_about_value)
rss.items << item
rss.items.last == item # => true
注意: item=/set_itemなどはRubyっぽくないので使わないでくださ
い.
=.......each do |fname|
feed = nil
begin
feed = RSS::Parser.parse(File.read(fname), false)
rescue RSS::Error
end
if feed.nil?
puts "#{fname}はRSS 0.9x/1.0/2.0, Atom 1.0のいずれでもありません。"
else
print_items(feed)
end
end
あとはprint_item... -
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......eb.resource.org/rss/1.0/modules/image/>))のサポート
=== 2005-02-03
: RSS::Element#convert(value) [lib] [new]
valueのエンコーディングを変換するメソッドを公開。
valueのエンコーディングは要素の内部エンコーディングからoutput_encoding=で設...