Module: Postsvg
- Defined in:
- lib/postsvg.rb,
lib/postsvg/cli.rb,
lib/postsvg/colors.rb,
lib/postsvg/errors.rb,
lib/postsvg/matrix.rb,
lib/postsvg/parser.rb,
lib/postsvg/version.rb,
lib/postsvg/converter.rb,
lib/postsvg/tokenizer.rb,
lib/postsvg/interpreter.rb,
lib/postsvg/path_builder.rb,
lib/postsvg/svg_generator.rb,
lib/postsvg/graphics_state.rb,
lib/postsvg/parser/transform.rb,
lib/postsvg/parser/postscript_parser.rb
Defined Under Namespace
Modules: Colors Classes: CLI, ConversionError, Converter, Error, GraphicsState, Interpreter, Matrix, ParseError, Parser, PathBuilder, SvgGenerator, Token, Tokenizer, UnsupportedOperatorError
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.convert(ps_content) ⇒ Object
Convert PostScript content to SVG.
-
.convert_file(input_path, output_path = nil) ⇒ Object
Convert PostScript file to SVG.
Class Method Details
.convert(ps_content) ⇒ Object
Convert PostScript content to SVG
11 12 13 14 15 16 17 18 19 |
# File 'lib/postsvg.rb', line 11 def convert(ps_content) bbox = extract_bounding_box(ps_content) tokens = Tokenizer.tokenize(ps_content) interpreter = Interpreter.new svg_out = interpreter.interpret(tokens, bbox) generate_svg(svg_out, bbox) end |
.convert_file(input_path, output_path = nil) ⇒ Object
Convert PostScript file to SVG
22 23 24 25 26 27 28 29 |
# File 'lib/postsvg.rb', line 22 def convert_file(input_path, output_path = nil) ps_content = File.read(input_path) svg_content = convert(ps_content) File.write(output_path, svg_content) if output_path svg_content end |