Class: WDD::Utils::PrettyXml

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/wdd-ruby-ext/utils/pretty_xml.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrettyXml

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.expand_path('../../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