るりまサーチ

最速Rubyリファレンスマニュアル検索!
592件ヒット [1-100件を表示] (0.142秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > クエリ:elements[x]

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle type_size_t

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

Vector.elements(a, copy = true) -> Vector (24219.0)

配列 a を要素とするベクトルを生成します。 ただし、オプション引数 copy が偽 (false) ならば、複製を行いません。

...Vectorを生成する際の要素の配列
@param copy 引数の配列 a のコピーをするかどうかのフラグ

//emlist[例][ruby]{
require 'matrix'
a = [1, 2, 3, 4]
v1 = Vector.elements(a, true)
v2 = Vector.elements(a, false)
p v1 # => Vector[1, 2, 3, 4]
p v2 # => Vector[1...
..., 2, 3, 4]
a[0] = -1
p v1 # => Vector[1, 2, 3, 4]
p v2 # => Vector[-1, 2, 3, 4]
//}...

Vector#elements_to_f -> Vector (15219.0)

ベクトルの各成分をFloatに変換したベクトルを返します。

...ベクトルの各成分をFloatに変換したベクトルを返します。

このメソッドは deprecated です。 map(&:to_f) を使ってください。

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

v = Vector.elements([2, 3, 5, 7, 9])
p v.elements_to_f
# => Vector[2.0, 3.0, 5.0, 7.0, 9.0]
//}...

Vector#elements_to_i -> Vector (15219.0)

ベクトルの各成分をIntegerに変換したベクトルを返します。

...ベクトルの各成分をIntegerに変換したベクトルを返します。

このメソッドは deprecated です。 map(&:to_i) を使ってください。

//emlist[例][ruby]{
require 'matrix'
v = Vector.elements([2.5, 3.0, 5.01, 7])
p v.elements_to_i
# => Vector[2, 3, 5, 7]
//}...

Vector#elements_to_r -> Vector (15219.0)

ベクトルの各成分をRationalに変換したベクトルを返します。

...クトルの各成分をRationalに変換したベクトルを返します。

このメソッドは deprecated です。 map(&:to_r) を使ってください。

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

v = Vector.elements([2.5, 3.0, 5.75, 7])
p v.elements_to_r
# => Vector[(5/2), (3/1), (23/4), (7/1)...

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

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

... 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? # => false
//}...

絞り込み条件を変える

REXML::Attributes#each_attribute {|attribute| ... } -> () (9212.0)

各属性に対しブロックを呼び出します。

...ML::Attribute オブジェクトで渡されます。

//emlist[][ruby]{
require 'rexml/document'

doc = REXML::Document.new(<<EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' att='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a")...
....first

a.attributes.each_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end
# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}...

REXML::Elements#delete(element) -> Element (9136.0)

element で指定した子要素を取り除きます。

...element で指定した子要素を取り除きます。

element には、REXML::Element、整数、文字列が指定できます。
Element オブジェクトを指定した場合は、その子要素を取り除きます。
整数を指定した場合には element 番目の子要素を削除し...
...ath で指定した場合、子要素ではない要素も取り除けることに注意してください。

@param element 削除する要素(REXML::Element, 整数, 文字列)

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

REXML::Elements#to_a(xpath = nil) -> [REXML::Element] (9124.0)

すべての子要素の配列を返します。

...す。

xpath を指定した場合は、その XPath 文字列に
マッチする要素の配列を返します。

REXML::Elements#each と同様、REXML::XPath.match などと
異なり、要素以外の子ノードは無視されます。

@param xpath XPath文字列

//emlist[][ruby]{
require '...
...rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.elements.to_a # => [<b/>, <c/>]
doc.root.elements.to_a("child::node()") # => [<b/>, <c/>]
REXML::XPath.match(doc.root, "child::node()") # => ["sean", <b/>, "elliott", <c/>]
//}...

REXML::Attributes#get_attribute(name) -> Attribute | nil (9112.0)

name という名前の属性を取得します。

...ttributes#[]

//emlist[][ruby]{
require 'rexml/document'

doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' att='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a").first

a.attributes.get_attribute("att...
...") # => att='&lt;'
a.attributes.get_attribute("foo:att") # => foo:att='1'
//}...
<< 1 2 3 ... > >>