class SVGPlot::Application
Application
object for running .svgplot files
Public Class Methods
new(*args)
click to toggle source
# File lib/svgplot/application.rb, line 5 def initialize(*args) @files = args.empty? ? Dir.glob(File.expand_path('*.svgplot')) : args fail('No input files') if @files.empty? end
Public Instance Methods
run!()
click to toggle source
# File lib/svgplot/application.rb, line 10 def run! @files.each do |file| output = file.sub(/\.svgplot/, '') + '.svg' File.open(output, 'w') { |fh| build file, fh } end end
Private Instance Methods
build(file, fh)
click to toggle source
# File lib/svgplot/application.rb, line 19 def build(file, fh) SVGPlot.new({ width: '100%', height: '100%' }, fh) do begin instance_eval File.read(file), file rescue StandardError => e regexp = Regexp.new(File.expand_path(file)) backtrace = e.backtrace.grep regexp raise e.class, e.message, backtrace end end end