るりまサーチ

最速Rubyリファレンスマニュアル検索!
812件ヒット [201-300件を表示] (0.197秒)

別のキーワード

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

ライブラリ

クラス

モジュール

検索結果

<< < 1 2 3 4 5 ... > >>

REXML::Element#add_attribute(key, value) -> () (15213.0)

要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。

...す方法と REXML::Attribute オブジェクトを
渡す方法です。

文字列2つで指定する場合、属性値は unnormalized な文字列を渡す必要があります。

@param key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブジェ...
...クト)

//emlist[][ruby]{
r
equire 'rexml/document'
doc = REXML::Document.new("<e/>")
doc.root.add_attribute("a", "b"); doc.root # => <e a='b'/>
doc.root.add_attribute("x:a", "c"); doc.root # => <e a='b' x:a='c'/>
doc.root.add_attribute(REXML::Attribute.new("b", "d"))
doc.root # => <e a='b' x:a='c'...

REXML::Element#prefixes -> [String] (15213.0)

self の文脈で定義されている prefix を文字列の配列を返します。

...いる prefix を文字列の配列を返します。

対象の要素とその外側の要素で定義されている prefix を返します。

//emlist[][ruby]{
r
equire 'rexml/document'
doc = REXML::Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
doc.elements['//b'].prefixes #...

REXML::Element#root_node -> REXML::Document | REXML::Node (15213.0)

self が属する文書のルートノードを返します。

...書(REXML::Document) オブジェクトが
返されます。

その要素が属する REXML::Document オブジェクトが存在しない
場合は木構造上のルートノードが返されます。

//emlist[][ruby]{
r
equire 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root>
<children>...
...<grandchildren />
</children>
</root>
EOS

children = doc.get_elements("/root/children").first
children.name # => "children"
children.root_node == doc # => true
grandchildren = doc.get_elements("/root/children/grandchildren").first
grandchildren.name # => "grandchildren"
grandchildren.root_node ==...
...doc # => true
//}...

REXML::DocType#attribute_of(element, attribute) -> String | nil (12660.0)

DTD 内の属性リスト宣言で、 element という名前の要素の attribute という 名前の属性のデフォルト値を返します。

...DTD 内の属性リスト宣言で、 element という名前の要素の attribute という
名前の属性のデフォルト値を返します。

element
という名前の要素の属性値は宣言されていない、
element
という名前の要素にはattributeという名前の属性が宣...
...@param element 要素名(文字列)
@param attribute 属性名(文字列)

//emlist[][ruby]{
r
equire 'rexml/document'

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book
author CDATA #REQUIRED
t
itle...
...CDATA #REQUIRED
publisher CDATA "foobar publisher">
]>
EOS

p doctype.attribute_of("book", "publisher") # => "foobar publisher"
p doctype.attribute_of("bar", "foo") # => nil
p doctype.attribute_of("book", "baz") # => nil
p doctype.attribute_of("book", "title") # => nil
//}...

REXML::DocType#attributes_of(element) -> [REXML::Attribute] (12542.0)

DTD 内の属性リスト宣言で、 element という名前の要素に対し宣言されている 属性の名前とデフォルト値を REXML::Attribute の配列で返します。

...TD 内の属性リスト宣言で、 element という名前の要素に対し宣言されている
属性の名前とデフォルト値を REXML::Attribute の配列で返します。

名前とデフォルト値のペアは、各 Attribute オブジェクトの
R
EXML::Attribute#name と
R
EXML::Att...
...ribute#value で表現されます。

//emlist[][ruby]{
r
equire 'rexml/document'

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (comment)>
<!ELEMENT comment (#PCDATA)>
<!ATTLIST book
author CDATA #REQUIRED
t
itle CDATA #REQUIRED
publisher...
...CDATA "foobar publisher">
]>
EOS

p doctype.attributes_of("book")
# => [author='', title='', publisher='foobar publisher']
p doctype.attributes_of("book")[0].name # => "author"
p doctype.attributes_of("book")[0].value # => ""
//}...

絞り込み条件を変える

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

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

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

element
には、REXML::Element、整数、文字列が指定できます。
Element
オブジェクトを指定した場合は、その子要素を取り除きます。
整数を指定した場合には element 番目の子要素を削除し...
...ます(1-originです)。
文字列を指定した場合は、削除する要素を XPath で指定します。
XPathが複数の要素を指している場合は、そのうち一つを削除します。

取り除かれた要素を返します。

XPath で指定した場合、子要素ではな...
...してください。

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

//emlist[][ruby]{
r
equire '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...

REXML::Attribute#to_string -> String (12337.0)

"name='value'" という形式の文字列を返します。

..."name='value'" という形式の文字列を返します。

//emlist[][ruby]{
r
equire 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("ns:r", "rval")
p e.attributes.get_attribute("r").to_string # => "ns:r='rval'"
//}...

Array#transpose -> Array (12319.0)

自身を行列と見立てて、行列の転置(行と列の入れ換え)を行いま す。転置した配列を生成して返します。空の配列に対しては空の配列を生 成して返します。

...
T
ypeError が発生します。各要素のサイズが不揃いな配列に対して
は、例外 IndexError が発生します。

//emlist[例][ruby]{
p [[1,2],
[3,4],
[5,6]].transpose
# => [[1, 3, 5], [2, 4, 6]]

p [].transpose
# => []

p [1,2,3].transpose

# => -:1:in `transpose': cannot...
...convert Fixnum into Array (TypeError)
# from -:1

p [[1,2],
[3,4,5],
[6,7]].transpose
# => -:3:in `transpose': element size differ (3 should be 2) (IndexError)
//}...

REXML::Elements#delete_all(xpath) -> [REXML::Element] (12314.0)

xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。

...xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。

@param xpath 取り除く要素を指し示す XPath 文字列

//emlist[][ruby]{
r
equire 'rexml/document'
doc = REXML::Document.new('<a><c/><c/><c/><c/></a>')
doc.elements.delete_all("a/c") # => [<c/>, <...
...c/>, <c/>, <c/>]
doc.to_s # => "<a/>"
//}...
<< < 1 2 3 4 5 ... > >>