class Topo::Converter
Attributes
input[RW]
topology[RW]
Public Class Methods
convert(data, format)
click to toggle source
# File lib/topo/converter.rb, line 59 def self.convert(data, format) converter = self.converter(format) converter.convert(data) end
converter(format)
click to toggle source
Get the right converter for the input format
# File lib/topo/converter.rb, line 43 def self.converter(format) converter_class = @@converter_classes[format] unless converter_class begin require "topo/converter/#{format}/converter" converter_class = @@converter_classes[format] rescue LoadError STDERR.puts("#{format} is not a known format for the topology file") exit 1 end end Object::const_get(converter_class).new(format) end
new(format, data=nil)
click to toggle source
# File lib/topo/converter.rb, line 66 def initialize(format, data=nil) @format = format @input = data @output = { "nodes" => [], "services" => [], "network" => [], "provisioning" => {} } end
register_converter(format, class_name)
click to toggle source
# File lib/topo/converter.rb, line 35 def self.register_converter(format, class_name) @@converter_classes[format] = class_name end
Public Instance Methods
convert(data=nil)
click to toggle source
Other format converters should override this method to convert to topo format data
# File lib/topo/converter.rb, line 73 def convert(data=nil) @input = data if data @output = @input @output end