Class: Stepmod::Utils::SmrlResourceConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/stepmod/utils/smrl_resource_converter.rb

Class Method Summary collapse

Class Method Details

.convert(input, options = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/stepmod/utils/smrl_resource_converter.rb', line 49

def self.convert(input, options = {})
  root = if input.is_a?(String)
            then Nokogiri::XML(input).root
          elsif input.is_a?(Nokogiri::XML::Document)
            then input.root
          elsif input.is_a?(Nokogiri::XML::Node)
            then input
          end

  root || (return '')

  ReverseAdoc.config.with(options) do
    result = ReverseAdoc::Converters.lookup(root.name).convert(root)
    Stepmod::Utils::Cleaner.new.tidy(result)
  end
end