Method: Inkmake::InkFile#initialize
- Defined in:
- lib/inkmake.rb
#initialize(file, opts) ⇒ InkFile
Returns a new instance of InkFile.
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/inkmake.rb', line 463 def initialize(file, opts) @file = file @images = [] @force = opts[:force] svg_path = nil out_path = nil File.read(file).lines.each_with_index do |line, index| line.strip! next if line.empty? or line.start_with? "#" begin case line when /^svg:(.*)/i then svg_path = File.($1.strip, File.dirname(file)) when /^out:(.*)/i then out_path = File.($1.strip, File.dirname(file)) else @images << InkImage.new(self, parse_line(line)) end rescue SyntaxError => e puts "#{file}:#{index+1}: #{e.message}" exit end end # order is: argument, config in inkfile, inkfile directory @svg_path = opts[:svg_path] || svg_path || File.dirname(file) @out_path = opts[:out_path] || out_path || File.dirname(file) end |