Module: Resync::XML
- Defined in:
- lib/resync/xml.rb
Overview
Helper methods and modules related to reading and writing XML.
Defined Under Namespace
Classes: ChangeNode, ChangefreqNode, HashCodesNode, MimeTypeNode, TimeNode, UriNode
Class Method Summary collapse
-
.element(xml) ⇒ REXML::Element
Extracts a
REXML::Elementfrom the specified object. -
.to_uri(url) ⇒ Object
Ensures that the provided value is a
URI, parsing it if necessary.
Class Method Details
.element(xml) ⇒ REXML::Element
Extracts a REXML::Element from the specified object.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/resync/xml.rb', line 28 def self.element(xml) case xml when REXML::Document xml.root when REXML::Element xml else fail ArgumentError, "Unexpected argument type; expected XML document, String, or IO source, was #{xml.class}" unless can_parse(xml) REXML::Document.new(xml).root end end |
.to_uri(url) ⇒ Object
Ensures that the provided value is a URI, parsing it if necessary.
16 17 18 19 |
# File 'lib/resync/xml.rb', line 16 def self.to_uri(url) return nil unless url (url.is_a? URI) ? url : URI.parse(url) end |