module XMLable::Mixins::Export

Export modules contains method to export

Public Instance Methods

to_h(opts = {}) click to toggle source

Export to hash

@param [Hash] opts

@return [Hash]

# File lib/xmlable/mixins/export.rb, line 40
def to_h(opts = {})
  Exports::JSONExporter.new(self, opts).export
end
to_json(opts = {}) click to toggle source

Export to JSON

@param [Hash] opts @option opts [Boolean] :pretty enable pretty print

@return [String] returns exported JSON

# File lib/xmlable/mixins/export.rb, line 28
def to_json(opts = {})
  ret = to_h(opts)
  opts[:pretty] ? JSON.pretty_generate(ret) : ret.to_json
end
to_xml(opts = {}) click to toggle source

Export to XML

@param [Hash] opts

@return [String] returns exported XML

# File lib/xmlable/mixins/export.rb, line 14
def to_xml(opts = {})
  exporter = Exports::XMLExporter.new(self, opts)
  opts = self.class.__nokogiri_export_options.merge(opts)
  exporter.export.to_xml(opts).strip
end