Class: RGeo::CoordSys::CS::WKTParser::ArgumentList
- Inherits:
-
Object
- Object
- RGeo::CoordSys::CS::WKTParser::ArgumentList
- Defined in:
- lib/rgeo/coord_sys/cs/wkt_parser.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#<<(value_) ⇒ Object
:nodoc:.
-
#assert_empty ⇒ Object
:nodoc:.
-
#create_optionals ⇒ Object
:nodoc:.
-
#find_all(klass_) ⇒ Object
:nodoc:.
-
#find_first(klass_) ⇒ Object
:nodoc:.
-
#initialize ⇒ ArgumentList
constructor
:nodoc:.
-
#shift(klass_ = nil) ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ ArgumentList
:nodoc:
211 212 213 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 211 def initialize # :nodoc: @values = [] end |
Instance Method Details
#<<(value_) ⇒ Object
:nodoc:
215 216 217 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 215 def <<(value_) # :nodoc: @values << value_ end |
#assert_empty ⇒ Object
:nodoc:
219 220 221 222 223 224 225 226 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 219 def assert_empty # :nodoc: if @values.size > 0 names_ = @values.map do |val_| val_.is_a?(Base) ? val_._wkt_typename : val_.inspect end raise Error::ParseError, "#{@values.size} unexpected arguments: #{names_.join(', ')}" end end |
#create_optionals ⇒ Object
:nodoc:
252 253 254 255 256 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 252 def create_optionals # :nodoc: hash_ = {} find_all(ExtensionClause).each { |ec_| hash_[ec_.key] = ec_.value } (find_first(AuthorityClause) || [nil, nil]).to_a + [nil, nil, nil, hash_] end |
#find_all(klass_) ⇒ Object
:nodoc:
238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 238 def find_all(klass_) # :nodoc: results_ = [] nvalues_ = [] @values.each do |val_| if val_.is_a?(klass_) results_ << val_ else nvalues_ << val_ end end @values = nvalues_ results_ end |
#find_first(klass_) ⇒ Object
:nodoc:
228 229 230 231 232 233 234 235 236 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 228 def find_first(klass_) # :nodoc: @values.each_with_index do |val_, index_| if val_.is_a?(klass_) @values.slice!(index_) return val_ end end nil end |
#shift(klass_ = nil) ⇒ Object
:nodoc:
258 259 260 261 262 263 264 265 266 267 |
# File 'lib/rgeo/coord_sys/cs/wkt_parser.rb', line 258 def shift(klass_ = nil) # :nodoc: val_ = @values.shift unless val_ raise Error::ParseError, "No arguments left... expected #{klass_}" end if klass_ && !val_.is_a?(klass_) raise Error::ParseError, "Expected #{klass_} but got #{val_.class}" end val_ end |