Class: Duxml::NodeSet
- Includes:
- Observable
- Defined in:
- lib/duxml/doc/node_set.rb
Overview
subclass of Array that is Observable by History used to track changes in String nodes of XML Element
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#[]=(index, str) ⇒ self
Reports old String and index to history.
-
#history ⇒ HistoryClass
Object that observes this NodeSet for changes.
-
#initialize(_parent, ary = []) ⇒ NodeSet
constructor
A new instance of NodeSet.
Constructor Details
#initialize(_parent, ary = []) ⇒ NodeSet
Returns a new instance of NodeSet.
17 18 19 20 |
# File 'lib/duxml/doc/node_set.rb', line 17 def initialize(_parent, ary=[]) super ary @parent = _parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'lib/duxml/doc/node_set.rb', line 13 def parent @parent end |
Instance Method Details
#[]=(index, str) ⇒ self
Returns reports old String and index to history.
30 31 32 33 34 35 36 37 |
# File 'lib/duxml/doc/node_set.rb', line 30 def []=(index, str) raise Exception if count_observers < 1 old_str = self[index] super(index, str) changed notify_observers(:ChangeText, parent, index, old_str) self end |
#history ⇒ HistoryClass
Returns object that observes this NodeSet for changes.
23 24 25 |
# File 'lib/duxml/doc/node_set.rb', line 23 def history @observer_peers.first.first if @observer_peers and @observer_peers.first.any? end |