Class: GeoRuby::SimpleFeatures::TokenizerStructure
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::TokenizerStructure
- Defined in:
- lib/geo_ruby/simple_features/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.
293 294 295 296 297 |
# File 'lib/geo_ruby/simple_features/ewkt_parser.rb', line 293 def initialize(ewkt) @ewkt = ewkt @scanner = StringScanner.new(ewkt) @regex = /\s*([\w.-]+)s*/ end |
Instance Method Details
#check_next_token ⇒ Object
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/geo_ruby/simple_features/ewkt_parser.rb', line 316 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
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/geo_ruby/simple_features/ewkt_parser.rb', line 299 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 |