Class REXML::Attributes
In: rexml/element.rb

A class that defines the set of Attributes of an Element and provides operations for accessing elements in that set.

ElementAttributesのセットを定義し、そのセットの中の要素にアクセ スする操作を提供するクラスです。

Methods
[]    []=    add    delete    delete_all    each    each_attribute    get_attribute    length    new    prefixes   
Public Class methods
new(element)

Constructor

element:the Element of which this is an Attribute

コンストラクタ

element:AttributeElementです。
Public Instance methods
[](name)

Fetches an attribute value. If you want to get the Attribute itself, use get_attribute()

name:an XPath attribute name. Namespaces are relevant here.
Returns:the String value of the matching attribute, or nil if no matching attribute was found.
 doc = Document.new "<a foo:att='1' bar:att='2' att='3'/>"
 doc.root.attributes['att']         #-> '3'
 doc.root.attributes['bar:att']     #-> '2'

属性の値を手に入れます。もし、あなたがAttributeをそれ自身から手 に入れたいのであれば、get_attribute()を使って下さい。

name:XPath属性の名前です。ここではネームスペースが関連します。
戻り値:マッチした属性のStringの値か、マッチしなかったらnilを返しま す。
 doc = Document.new "<a foo:att='1' bar:att='2' att='3'/>"
 doc.root.attributes['att']         #-> '3'
 doc.root.attributes['bar:att']     #-> '2'
length()

Returns the number of attributes the owning Element contains.

 doc = Document "<a x='1' y='2' foo:x='3'/>"
 doc.root.attributes.length        #-> 3

Element自身がが含んでいる属性の数を返します。

 doc = Document "<a x='1' y='2' foo:x='3'/>"
 doc.root.attributes.length        #-> 3
each_attribute() {|attribute| ...}

Itterates over the attributes of an Element. Yields actual Attribute nodes, not String values.

 doc = Document.new '<a x="1" y="2"/>'
 doc.root.attributes.each_attribute {|attr|
   p attr.expanded_name+" => "+attr.value
 }

Elementの各属性を繰り返します。Stringの値ではなくて、実際の Attributeノードでyieldします。

 doc = Document.new '<a x="1" y="2"/>'
 doc.root.attributes.each_attribute {|attr|
   p attr.expanded_name+" => "+attr.value
 }
each() {|attr.expanded_name, attr.value| ...}

Itterates over each attribute of an Element, yielding the expanded name and value as a pair of Strings.

 doc = Document.new '<a x="1" y="2"/>'
 doc.root.attributes.each {|name, value| p name+" => "+value }

Elementの各要素を繰り返します。Stringのペアとして拡張された名前 と値をyieldします。

 doc = Document.new '<a x="1" y="2"/>'
 doc.root.attributes.each {|name, value| p name+" => "+value }
get_attribute( name )

Fetches an attribute

name:the name by which to search for the attribute. Can be a prefix:name namespace name.
Returns:The first matching attribute, or nil if there was none. This

value is an Attribute node, not the String value of the attribute.

 doc = Document.new '<a x:foo="1" foo="2" bar="3"/>'
 doc.root.attributes.get_attribute("foo").value    #-> "2"
 doc.root.attributes.get_attribute("x:foo").value  #-> "1"

属性を手に入れます。

name:属性を検索するための名前です。prefix:nameネームスペー ス名も可能です。
戻り値:最初にマッチした属性、マッチしなければnilを返します。この値は Attributeノードであって、属性のStringの値ではありません。
 doc = Document.new '<a x:foo="1" foo="2" bar="3"/>'
 doc.root.attributes.get_attribute("foo").value    #-> "2"
 doc.root.attributes.get_attribute("x:foo").value  #-> "1"
[]=( name, value )

Sets an attribute, overwriting any existing attribute value by the same name. Namespace is significant.

name:the name of the attribute
value:(optional) If supplied, the value of the attribute. If nil, any existing matching attribute is deleted.
Returns:Owning element
 doc = Document.new "<a x:foo='1' foo='3'/>"
 doc.root.attributes['y:foo'] = '2'
 doc.root.attributes['foo'] = '4'
 doc.root.attributes['x:foo'] = nil

存在している同じ名前のいかなる属性の値も上書きして属性を設定しま す。ネームスペースは意味があります。

name:属性の名前です。
value:(任意(オプション))もし、与えられていれば、属性の値になります。 もし、nilなら、存在しているマッチしたいかなる属性も削除されま す。
戻り値:自分自身の要素を返します。
 doc = Document.new "<a x:foo='1' foo='3'/>"
 doc.root.attributes['y:foo'] = '2'
 doc.root.attributes['foo'] = '4'
 doc.root.attributes['x:foo'] = nil
prefixes()

Returns an array of Strings containing all of the prefixes declared by this set of # attributes. The array does not include the default namespace declaration, if one exists.

 doc = Document.new("<a xmlns='foo' xmlns:x='bar' xmlns:y='twee' "+
       "z='glorp' p:k='gru'/>")
 prefixes = doc.root.attributes.prefixes    #-> ['x', 'y']

この属性の設定によって宣言されている接頭辞を含んだ全てをStringの 配列で返します。もし、存在しても、この配列はデフォルトのネームス ペース宣言を含みません。

 doc = Document.new("<a xmlns='foo' xmlns:x='bar' xmlns:y='twee' "+
       "z='glorp' p:k='gru'/>")
 prefixes = doc.root.attributes.prefixes    #-> ['x', 'y']
delete( attribute )

Removes an attribute

attribute:either a String, which is the name of the attribute to remove -- namespaces are significant here -- or the attribute to remove.
Returns:the owning element
 doc = Document.new "<a y:foo='0' x:foo='1' foo='3' z:foo='4'/>"
 doc.root.attributes.delete 'foo'   #-> <a y:foo='0' x:foo='1' z:foo='4'/>"
 doc.root.attributes.delete 'x:foo' #-> <a y:foo='0' z:foo='4'/>"
 attr = doc.root.attributes.get_attribute('y:foo')
 doc.root.attributes.delete attr    #-> <a z:foo='4'/>"

属性を取り除きます。

attribute:取り除く属性の名前(ここではネームスペースは意味も持ちます)の Stringか、取り除く属性です。
戻り値:自分自身の要素です。
 doc = Document.new "<a y:foo='0' x:foo='1' foo='3' z:foo='4'/>"
 doc.root.attributes.delete 'foo'   #-> <a y:foo='0' x:foo='1' z:foo='4'/>"
 doc.root.attributes.delete 'x:foo' #-> <a y:foo='0' z:foo='4'/>"
 attr = doc.root.attributes.get_attribute('y:foo')
 doc.root.attributes.delete attr    #-> <a z:foo='4'/>"
add( attribute )

Adds an attribute, overriding any existing attribute by the same name. Namespaces are significant.

attribute:An Attribute

存在する同じ名前のいかなる属性を上書きして属性を追加します。 ネームスペースは意味を持ちます。

attribute:属性です。
delete_all( name )

Deletes all attributes matching a name. Namespaces are significant.

name:A String; all attributes that match this path will be removed
Returns:an Array of the Attributes that were removed

nameにマッチする全ての属性を削除します。ネームスペースは意味を持 ちます。

name:Stringです。;このパスにマッチする全ての属性が削除されるでしょ う。
戻り値:削除された属性の配列です。