377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
# File 'lib/pixelart/image.rb', line 377
def self.parse_pixels_strict( rx, txt )
pixels = []
txt.each_line do |line|
line = line.strip
next if line.start_with?( '#' ) || line.empty?
scan = StringScanner.new( line )
tokens = []
loop do
token = scan.scan( rx )
if token.nil?
puts "!! ERROR - parse error; expected match of #{rx.to_s} but got: #{scan.rest}"
exit 1
end
tokens << token
scan.skip( /[ \t]+/ )
break if scan.eos?
end
pixels << tokens
end
pixels
end
|