Class: Rexslt

Inherits:
Object
  • Object
show all
Defined in:
lib/rexslt.rb

Instance Method Summary collapse

Constructor Details

#initialize(xsl, xml, raw_params = {}, debug: false) ⇒ Rexslt

Returns a new instance of Rexslt.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rexslt.rb', line 68

def initialize(xsl, xml, raw_params={}, debug: false)

  ## debugging variables

  @rn = 0
  @rre = 0

  super()
  puts 'before options'.info if @debug
  @options = {}

  params = raw_params.merge({debug: false})
  @debug = debug
  custom_params = params.inject({}){|r,x| r.merge(Hash[x[0].to_s,x[1]])}
  puts 'before xsl_transform'.info if @debug

  xslt_transform(*[xsl, xml].map{|x| RXFReader.read(x).first}, custom_params)
end

Instance Method Details

#to_docObject



91
# File 'lib/rexslt.rb', line 91

def to_doc(); @doc; end

#to_s(options = {}) ⇒ Object



87
88
89
# File 'lib/rexslt.rb', line 87

def to_s(options={})
  @doc.to_s(@options.merge(options)).sub(/<root4>/,'').sub(/<\/root4>$/m,'').lstrip
end

#to_xmlObject



93
94
95
# File 'lib/rexslt.rb', line 93

def to_xml()
  @doc.root.xml(pretty: true).sub(/<root4>/,'').sub(/<\/root4>$/m,'')
end