Class: RGeo::CoordSys::CS::WKTParser::ArgumentList

Inherits:
Object
  • Object
show all
Defined in:
lib/rgeo/coord_sys/cs/wkt_parser.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeArgumentList

Returns a new instance of ArgumentList.



245
246
247
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 245

def initialize
  @values = []
end

Instance Method Details

#<<(value_) ⇒ Object



249
250
251
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 249

def <<(value_)
  @values << value_
end

#assert_emptyObject



253
254
255
256
257
258
259
260
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 253

def assert_empty
  if @values.size > 0
    names_ = @values.map do |val_|
      val_.kind_of?(Base) ? val_._wkt_typename : val_.inspect
    end
    raise Error::ParseError, "#{@remaining} unexpected arguments: #{names_.join(', ')}"
  end
end

#find_all(klass_) ⇒ Object



272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 272

def find_all(klass_)
  results_ = []
  nvalues_ = []
  @values.each do |val_|
    if val_.kind_of?(klass_)
      results_ << val_
    else
      nvalues_ << val_
    end
  end
  @values = nvalues_
  results_
end

#find_first(klass_) ⇒ Object



262
263
264
265
266
267
268
269
270
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 262

def find_first(klass_)
  @values.each_with_index do |val_, index_|
    if val_.kind_of?(klass_)
      @values.slice!(index_)
      return val_
    end
  end
  nil
end

#shift(klass_ = nil) ⇒ Object



286
287
288
289
290
291
292
293
294
295
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 286

def shift(klass_=nil)
  val_ = @values.shift
  unless val_
    raise Error::ParseError, "No arguments left... expected #{klass_}"
  end
  if klass_ && !val_.kind_of?(klass_)
    raise Error::ParseError, "Expected #{klass_} but got #{val_.class}"
  end
  val_
end