Class: SVGPlot::Application

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

Overview

Application object for running .svgplot files

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Application

Returns a new instance of Application.



5
6
7
8
# 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

Instance Method Details

#run!Object



10
11
12
13
14
15
# 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