class NoaaNceiWeather::DataCategory

Class for querying against the /datacategory endpoint of the NOAA API

Public Class Methods

find(id) click to toggle source

Finds a specific instance of {DataCategory} by its ID

@param id [String] String ID of the resource. @return [DataCategory, nil] Instance of {DataCategory}, or nil if none found.

Calls superclass method
# File lib/noaa_ncei_weather/data_category.rb, line 52
def self.find(id)
  data = super(@@endpoint + "/#{id}")
  if data && data.any?
    self.new data['id'], data['name']
  else
    nil
  end
end
where(params = {}) click to toggle source

Retrieves a set of {DataCategory DataCategories} based on the parameters given

@param params [Hash] Hash to set filters on the request sent to the NOAA API @option params [String] :datasetid String ID of a {Dataset} @option params [Dataset] :dataset {Dataset} object @option params [String] :locationid String ID of a {Location} @option params [Location] :location {Location} object @option params [String] :stationid String ID of a {Station} @option params [Station] :station {Station} object @option params [String] :sortfield ('id') Accepts string values 'id', 'name,

'mindate', 'maxdate', and 'datacoverage' to sort data before being returned

@option params [String] :sortorder ('asc') Accepts 'asc' or 'desc' for sort order @option params [Integer] :limit Set a limit to the amount of records returned @option params [Integer] :offset (0) Used to offset the result list @return [Array<DataCategory>] Array of {DataCategory} objects that match the filter.

Calls superclass method
# File lib/noaa_ncei_weather/data_category.rb, line 76
def self.where(params = {})
  data = super(@@endpoint, params)
  if data && data.any?
    data.collect { |item| self.new(item['id'], item['name']) }
  else
    []
  end
end

Public Instance Methods

data_types(params = {}) click to toggle source

Retrieves the {DataType DataTypes} associated with a {DataCategory} object {DataCategory} has a one to many relationship with {DataType} (in rare cases a DataType may belong to more than one DataCategory)

@param params [Hash] See {DataType.where} for valid param key/values @return [Array<DataType>] Array of the data types associated with this

{DataCategory} instance
# File lib/noaa_ncei_weather/data_category.rb, line 21
def data_types(params = {})
  params.merge!({datacategoryid: @id})
  DataType.where(params)
end
locations(params = {}) click to toggle source

Retrieves the {Location Locations} associated with a {DataCategory} object. {Location} and {DataCategory} have a many to many relationship.

@param params [Hash] See {Location.where} for valid param key/values @return [Array<DataType>] Array of the data types associated with this

DataCategory instance
# File lib/noaa_ncei_weather/data_category.rb, line 32
def locations(params = {})
  params.merge!({datacategoryid: @id})
  Location.where(params)
end
stations(params = {}) click to toggle source

Retrieves the {Station Stations} associated with a {DataCategory} object {Station} and {DataCategory} have a many to many relationship.

@param params [Hash] See {Station.where} for valid param key/values @return [Array<DataType>] Array of the data types associated with this

DataCategory instance
# File lib/noaa_ncei_weather/data_category.rb, line 43
def stations(params = {})
  params.merge!({datacategoryid: @id})
  Station.where(params)
end