Class: WDD::Utils::PrettyXml
- Includes:
- Singleton
- Defined in:
- lib/wdd-ruby-ext/utils/pretty_xml.rb
Class Method Summary collapse
Instance Method Summary collapse
- #format(source) ⇒ Object
-
#initialize ⇒ PrettyXml
constructor
A new instance of PrettyXml.
Constructor Details
#initialize ⇒ PrettyXml
Returns a new instance of PrettyXml.
11 12 13 |
# File 'lib/wdd-ruby-ext/utils/pretty_xml.rb', line 11 def initialize @xsl ||= Nokogiri::XSLT(File.open(File.('../../resources/pretty_xml.xsl', __FILE__))) end |
Class Method Details
.format(source) ⇒ Object
21 22 23 |
# File 'lib/wdd-ruby-ext/utils/pretty_xml.rb', line 21 def format source PrettyXml.instance.format( source ) end |
Instance Method Details
#format(source) ⇒ Object
15 16 17 18 |
# File 'lib/wdd-ruby-ext/utils/pretty_xml.rb', line 15 def format source source = Nokogiri(source) if source.is_a? String @xsl.apply_to(source).to_s end |