Module: XmlUtil
- Defined in:
- lib/abelard/postxml.rb
Class Method Summary collapse
- .child_attribute(node, elementname, attributename) ⇒ Object
- .child_content(node, elementname) ⇒ Object
- .self_link(node) ⇒ Object
- .with_attribute(node, attributename, attributevalue) ⇒ Object
Class Method Details
.child_attribute(node, elementname, attributename) ⇒ Object
8 9 10 11 12 |
# File 'lib/abelard/postxml.rb', line 8 def self.child_attribute(node, elementname, attributename) el = node.children.find { |n| n.name == elementname } attr = el && el.attributes.get_attribute("term") attr && attr.value end |
.child_content(node, elementname) ⇒ Object
4 5 6 7 |
# File 'lib/abelard/postxml.rb', line 4 def self.child_content(node, elementname) el = node.children.find { |n| n.name == elementname } el && el.content end |
.self_link(node) ⇒ Object
17 18 19 20 |
# File 'lib/abelard/postxml.rb', line 17 def self.self_link(node) el = node.children.find { |l| (l.name == "link") && with_attribute(l, "rel", "self") } el && el.attributes.get_attribute("href").value end |
.with_attribute(node, attributename, attributevalue) ⇒ Object
13 14 15 16 |
# File 'lib/abelard/postxml.rb', line 13 def self.with_attribute(node, attributename, attributevalue) a = node.attributes.get_attribute(attributename) a && (a.value == attributevalue) end |