Class: SvgExport::CommandWrapper
- Inherits:
-
Object
- Object
- SvgExport::CommandWrapper
- Defined in:
- app/services/svg_export/command_wrapper.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #call ⇒ Object
- #filename ⇒ Object
-
#initialize(params, options) ⇒ CommandWrapper
constructor
A new instance of CommandWrapper.
- #type ⇒ Object
Constructor Details
#initialize(params, options) ⇒ CommandWrapper
Returns a new instance of CommandWrapper.
4 5 6 7 8 9 10 |
# File 'app/services/svg_export/command_wrapper.rb', line 4 def initialize(params, ) @params = params @allowed_types = Engine.[:allowed_types] @tmp_path = Engine.[:tmp_path] @svg_transformer = Engine.[:svg_transformer] @options = end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'app/services/svg_export/command_wrapper.rb', line 3 def params @params end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/svg_export/command_wrapper.rb', line 12 def call transformer = @svg_transformer.new(@options) svg = transformer.transform(params[:svg]) infile.write(svg) infile.flush result = run! fs = File.size?( outfile.path) if fs.nil? || fs < 10 raise SvgExport::Error.new( "Output file empty; #{result}") end File.open(outfile) end |
#filename ⇒ Object
25 26 27 28 |
# File 'app/services/svg_export/command_wrapper.rb', line 25 def filename base = params[:filename].blank? ? "chart" : params[:filename] "#{base}.#{ext}" end |