Class: Zt::Exporters::Exporter

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

Instance Method Summary collapse

Constructor Details

#initialize(*exporter_names) ⇒ Exporter

Returns a new instance of Exporter.



10
11
12
13
14
15
# File 'lib/zt/exporters.rb', line 10

def initialize(*exporter_names)
  exporter_names = Zt::Constants::ALL_EXPORTERS if exporter_names.empty?

  exporter_classes = exporter_names.map { |n| Zt::Exporters.const_get(n) }
  @exporters = exporter_classes.map(&:new)
end

Instance Method Details

#exportArray[Hash]

The hash is in form { data: Object, mangle: lambda } with the :mangle lambda containing any steps to apply the Object like rewriting /etc/hosts or sending the data elsewhere. NOTE there may be value in attributing each hash to its importer, consider that for later as a Hash.

Returns:

  • (Array[Hash])

    an array of hashes from each exporter



23
24
25
# File 'lib/zt/exporters.rb', line 23

def export
  @exporters.map(&:export)
end

#export_one_format(format) ⇒ Object



27
28
29
# File 'lib/zt/exporters.rb', line 27

def export_one_format(format)
  Zt::Exporters::HostsFileExporter.new.export if format == :hosts
end