るりまサーチ

最速Rubyリファレンスマニュアル検索!
818件ヒット [1-100件を表示] (0.131秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

Matrix#element(i, j) -> () (15108.0)

(i,j)要素を返します。 行列の範囲外の値を指定した場合には nil を返します。

...@param i 要素の行成分を0オリジンで指定します。
@param j 要素の列成分を0オリジンで指定します。



//emlist[例][ruby]{
require 'matrix'

a1 = [1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, 2, 1.5]
m = Matrix[a1, a2, a3]

p m[0, 0] # => 1
p m[1, 1] # => 15
p m[1, 2] # => 20...

REXML::Element#add_element(element, attrs = nil) -> Element (9370.0)

子要素を追加します。

...子要素を追加します。

element
として追加する要素を指定します。
REXML::Element オブジェクトもしくは文字列を指定します。

element
として REXML::Element オブジェクトを指定した場合、それが追加されます。
文字列を指定した場...
...す。

@param element 追加する要素
@param attrs 追加する要素に設定する属性

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a/>')
el = doc.root.add_element 'my-tag' # => <my-tag/>
doc.root.to_s # => "<a><my-tag/></a>"
el = doc.root.add_element 'my-tag', {'a...
...'val1' attr2='val2'/>
doc.root.to_s # => "<a><my-tag/><my-tag attr1='val1' attr2='val2'/></a>"
el = REXML::Element.new 'my-tag'
doc.root.add_element el # => <my-tag/>
doc.root.to_s # => "<a><my-tag/><my-tag attr1='val1' attr2='val2'/><my-tag/></a>"
//}

@see REXML::Elements#add, REXML::Element.new...

REXML::Element#delete_element(element) -> REXML::Element (9370.0)

子要素を削除します。

...を削除します。

element
で削除する要素を指定できます。整数、文字列、REXML::Element
オブジェクトのいずれかが指定できます。

REXML::Element を指定すると、その要素が削除されます。
整数を指定すると、element 番目の要素を削...
...されます。

@param element 削除する要素
@see REXML::Elements#delete

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/><c/><c id="1"/><d/><c/></a>'
doc.delete_element("/a/b")
doc.to_s # => "<a><c/><c id='1'/><d/><c/></a>"
doc.delete_element("a/c[@id='1']")
doc.t...
...o_s # => "<a><c/><d/><c/></a>"
doc.root.delete_element("c")
doc.to_s # => "<a><d/><c/></a>"
doc.root.delete_element("c")
doc.to_s # => "<a><d/></a>"
doc.root.delete_element(1)
doc.to_s # => "<a/>"
//}...

REXML::Element#each_element_with_attribute(key, value = nil, max = 0, name = nil) {|element| ... } -> () (9233.0)

特定の属性を持つすべての子要素を引数としてブロックを呼び出します。

...am name xpath文字列

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b id='1'/><c id='2'/><d id='1'/><e/></a>")
doc.root.each_element_with_attribute('id'){|e| p e }
# >> <b id='1'/>
# >> <c id='2'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1'){|e| p e...
...}
# >> <b id='1'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1', 1){|e| p e }
# >> <b id='1'/>
doc.root.each_element_with_attribute('id', '1', 0, 'd'){|e| p e }
# >> <d id='1'/>
//}...

REXML::Element#each_element_with_text(text = nil, max = 0, name = nil) {|element| ... } -> () (9233.0)

テキストを子ノードとして 持つすべての子要素を引数としてブロックを呼び出します。

...ist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
doc.root.each_element_with_text {|e|p e}
# >> <b> ... </>
# >> <c> ... </>
# >> <d> ... </>
doc.root.each_element_with_text('b'){|e|p e}
# >> <b> ... </>
# >> <c> ... </>
doc.root.each_element_with_...
...text('b', 1){|e|p e}
# >> <b> ... </>
doc.root.each_element_with_text(nil, 0, 'd'){|e|p e}
# >> <d> ... </>
//}...

絞り込み条件を変える

REXML::Element#next_element -> Element | nil (9221.0)

次の兄弟要素を返します。

...次の兄弟要素を返します。

次の要素が存在しない場合は nil を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b/>text<c/></a>'
doc.root.elements['b'].next_element # => <c/>
doc.root.elements['c'].next_element # => nil
//}...

REXML::Element#has_elements? -> bool (9107.0)

self が一つでも子要素を持つならば true を返します。

...emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b/><c>Text</c></a>")
doc.root.has_elements? # => true
doc.elements["/a/b"].has_elements? # => false
# /a/c はテキストノードしか持たないので false である
doc.elements["/a/c"].has_elements? # =...

Module#ruby2_keywords(method_name, ...) -> nil (6164.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...l hash argument is marked with a special
flag such that if it is the final element of a normal argument splat to
another method call, and that method call does not include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed thro...
...ate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
before 2.7, check that the module responds to this method befo...
...aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module Mod
def foo(meth, *args, &block)
send(:"do_#{meth}", *args, &block)
end
ruby
2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
end
//}...

Proc#ruby2_keywords -> proc (6164.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...l hash
argument is marked with a special flag such that if it is the final
element
of a normal argument splat to another method call, and that
method call does not include explicit keywords or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
be passed thr...
...ate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
before 2.7, check that the proc responds to this method before...
...so, be aware that if this method is removed, the behavior of the
proc will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
foo = ->(meth, *args, &block) do
send(:"do_#{meth}", *args, &block)
end
foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords)
end
//}...
<< 1 2 3 ... > >>