Class: GeoRuby::SimpleFeatures::TokenizerStructure
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::TokenizerStructure
- Defined in:
- lib/geo_ruby/ewk/ewkt_parser.rb
Instance Method Summary collapse
- #check_next_token ⇒ Object
- #get_next_token ⇒ Object
-
#initialize(ewkt) ⇒ TokenizerStructure
constructor
A new instance of TokenizerStructure.
Constructor Details
#initialize(ewkt) ⇒ TokenizerStructure
Returns a new instance of TokenizerStructure.
281 282 283 284 285 |
# File 'lib/geo_ruby/ewk/ewkt_parser.rb', line 281 def initialize(ewkt) @ewkt = ewkt @scanner = StringScanner.new(ewkt) @regex = /\s*([\w.-]+)s*/ end |
Instance Method Details
#check_next_token ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/geo_ruby/ewk/ewkt_parser.rb', line 303 def check_next_token check = @scanner.check(@regex) if check.nil? if @scanner.eos? nil else pos = @scanner.pos while @ewkt[pos].chr == ' ' pos += 1 end @ewkt[pos].chr end else check end end |
#get_next_token ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/geo_ruby/ewk/ewkt_parser.rb', line 287 def get_next_token if @scanner.scan(@regex).nil? if @scanner.eos? nil else ch = @scanner.getch while ch == ' ' ch = @scanner.getch end ch end else @scanner[1] end end |