class STAC::Client::ItemCollection

Represents STAC API - ItemCollection Fragment.

Attributes

features[RW]
number_matched[RW]
number_returned[RW]

Public Class Methods

from_hash(hash) click to toggle source
Calls superclass method
# File lib/stac/client/item_collection.rb, line 10
def from_hash(hash)
  h = hash.dup
  h['features'] = h.fetch('features').map { |feature| Item.from_hash(feature) }
  h['links'] ||= []
  h['number_matched'] = h.delete('numberMatched')
  h['number_returned'] = h.delete('numberReturned')
  super(h)
rescue KeyError => e
  raise ArgumentError, "required field not found: #{e.key}"
end
new(features:, links: [], number_matched: nil, number_returned: nil, stac_extensions: nil, **extra) click to toggle source
Calls superclass method
# File lib/stac/client/item_collection.rb, line 24
def initialize(features:, links: [], number_matched: nil, number_returned: nil, stac_extensions: nil, **extra)
  super(links: links, stac_extensions: stac_extensions, **extra)
  @features = features
  @number_matched = number_matched
  @number_returned = number_returned
end

Public Instance Methods

to_h() click to toggle source
Calls superclass method
# File lib/stac/client/item_collection.rb, line 31
def to_h
  super.except('stac_version').merge(
    {
      'numberMatched' => number_matched,
      'numberReturned' => number_returned,
      'features' => features.map(&:to_h),
    }.compact,
  )
end