Class: BmmlExporters::BmmlExporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*opts) ⇒ BmmlExporter



13
14
15
# File 'lib/bmmlexporter.rb', line 13

def initialize(*opts)
	set_options(*opts)
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



12
13
14
# File 'lib/bmmlexporter.rb', line 12

def opts
  @opts
end

Instance Method Details

#check_response_and_call(obj, method_symbol, *args) ⇒ Object



51
52
53
54
# File 'lib/bmmlexporter.rb', line 51

def check_response_and_call(obj, method_symbol, *args)
	raise 'The exporter '+obj.class.to_s+' does not respond to the method '+method_symbol.to_s unless obj and obj.respond_to?(method_symbol)
	obj.send(method_symbol, *args)
end

#exportObject



38
39
40
# File 'lib/bmmlexporter.rb', line 38

def export
	check_response_and_call(@exporter, :export)
end

#export!Object



46
47
48
49
# File 'lib/bmmlexporter.rb', line 46

def export!
	export
	save
end

#saveObject



42
43
44
# File 'lib/bmmlexporter.rb', line 42

def save
	check_response_and_call(@exporter, :save)
end

#set_options(*opts) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bmmlexporter.rb', line 21

def set_options(*opts)
	options = *opts

	raise "Require :import parameter" if options[:import].to_s.nil?
	raise "Require :export_type parameter" if options[:export_type].to_s.nil?

	if options[:import].eql? "file"
		raise "Require :file if :import => 'file'" if options[:file].nil?
	end

	raise "Require a valid :export_type: html / flex, mentioned " + options[:export_type] unless options[:export_type].eql? 'html' or options[:export_type].eql? 'flex'

	# Reminder: :import (file,inline), :file(name.bmml), :export_type (html/flex), :export_folder('./output')
	@exporter = options[:exporter]
	check_response_and_call(@exporter, :set_options, options)
end

#to_sObject



17
18
19
# File 'lib/bmmlexporter.rb', line 17

def to_s
	check_response_and_call(@exporter, :to_s)
end