Class: REXML::Object::ClassifiedElementList
- Inherits:
-
ReflectiveElementList
- Object
- ReflectiveElementList
- REXML::Object::ClassifiedElementList
- Defined in:
- lib/voruby/misc/rexml_ext.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Attributes inherited from ReflectiveElementList
Instance Method Summary collapse
- #<<(obj) ⇒ Object
- #==(ary) ⇒ Object
- #[](i) ⇒ Object
- #[]=(i, obj) ⇒ Object
- #clear ⇒ Object
- #each ⇒ Object
- #first ⇒ Object
-
#initialize(klass, parent, *xpath) ⇒ ClassifiedElementList
constructor
A new instance of ClassifiedElementList.
- #last ⇒ Object
- #replace(ary) ⇒ Object
- #to_a ⇒ Object
Methods inherited from ReflectiveElementList
Constructor Details
#initialize(klass, parent, *xpath) ⇒ ClassifiedElementList
Returns a new instance of ClassifiedElementList.
73 74 75 76 |
# File 'lib/voruby/misc/rexml_ext.rb', line 73 def initialize(klass, parent, *xpath) @klass = klass super(parent, *xpath) end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
71 72 73 |
# File 'lib/voruby/misc/rexml_ext.rb', line 71 def klass @klass end |
Instance Method Details
#<<(obj) ⇒ Object
87 88 89 |
# File 'lib/voruby/misc/rexml_ext.rb', line 87 def <<(obj) super(obj.node) end |
#==(ary) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/voruby/misc/rexml_ext.rb', line 116 def ==(ary) return false if self.size != ary.size self.each_with_index do |item, i| return false if item != ary[i] end return true end |
#[](i) ⇒ Object
78 79 80 |
# File 'lib/voruby/misc/rexml_ext.rb', line 78 def [](i) self.klass.new(super(i)) end |
#[]=(i, obj) ⇒ Object
82 83 84 85 |
# File 'lib/voruby/misc/rexml_ext.rb', line 82 def []=(i, obj) el = self[i] el ? el.node.replace_with(obj.node) : self<<(obj.node) end |
#clear ⇒ Object
112 113 114 |
# File 'lib/voruby/misc/rexml_ext.rb', line 112 def clear self.each { |el| el.node.remove } end |
#each ⇒ Object
108 109 110 |
# File 'lib/voruby/misc/rexml_ext.rb', line 108 def each XPath.each(self.parent, *self.xpath) { |el| yield self.klass.new(el) } end |
#first ⇒ Object
95 96 97 |
# File 'lib/voruby/misc/rexml_ext.rb', line 95 def first self.klass.new(super()) end |
#last ⇒ Object
91 92 93 |
# File 'lib/voruby/misc/rexml_ext.rb', line 91 def last self.klass.new(super()) end |
#replace(ary) ⇒ Object
103 104 105 106 |
# File 'lib/voruby/misc/rexml_ext.rb', line 103 def replace(ary) self.clear ary.each { |obj| self<<(obj) } end |
#to_a ⇒ Object
99 100 101 |
# File 'lib/voruby/misc/rexml_ext.rb', line 99 def to_a super().collect{ |el| self.klass.new(el) } end |