Module: ConDuxml::Instance
- Included in:
- Link
- Defined in:
- lib/con_duxml/instance.rb
Overview
Instances are copies of another XML element with a distinct set of parameter values like Objects in relation to a Class
Instance Method Summary collapse
-
#activate ⇒ Array[Element, String]
Array (or NodeSet) of either shallow clone of child nodes or referenced nodes @see #ref=.
-
#ref=(target) ⇒ Element
Self.
-
#resolve_ref(attr = 'ref') ⇒ Element
Either root node of referenced Doc or referenced node.
Instance Method Details
#activate ⇒ Array[Element, String]
Returns array (or NodeSet) of either shallow clone of child nodes or referenced nodes @see #ref=.
28 29 30 |
# File 'lib/con_duxml/instance.rb', line 28 def activate [resolve_ref || nodes].flatten.clone end |
#ref=(target) ⇒ Element
Returns self.
10 11 12 13 |
# File 'lib/con_duxml/instance.rb', line 10 def ref=(target) raise Exception unless doc.locate(target) or File.exists?(target) self[:ref] = target end |
#resolve_ref(attr = 'ref') ⇒ Element
Returns either root node of referenced Doc or referenced node.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/con_duxml/instance.rb', line 16 def resolve_ref(attr='ref') source = if self[:file] path = File.(File.dirname(doc.path) + '/' + self[:file]) sax path else doc end return source.locate(self[attr]).first if self[attr] source.root if self[:file] end |