Class: Emfsvg::Svg::PathData::Scanner
- Inherits:
-
Object
- Object
- Emfsvg::Svg::PathData::Scanner
- Defined in:
- lib/emfsvg/svg/path_data.rb
Overview
Character-stream tokenizer for path data. Emits command letters as Symbols (e.g. :M, :z) and numbers as Floats.
Constant Summary collapse
- NUMBER_RE =
/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/
Instance Method Summary collapse
-
#initialize(string) ⇒ Scanner
constructor
A new instance of Scanner.
- #next_token ⇒ Object
Constructor Details
#initialize(string) ⇒ Scanner
Returns a new instance of Scanner.
90 91 92 93 |
# File 'lib/emfsvg/svg/path_data.rb', line 90 def initialize(string) @string = string @pos = 0 end |
Instance Method Details
#next_token ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/emfsvg/svg/path_data.rb', line 95 def next_token skip_separators return nil if @pos >= @string.length char = @string[@pos] if command_letter?(char) @pos += 1 char.to_sym else read_number end end |