class NoaaNceiWeather::DataType
Class for querying against the /datacategory endpoint of the NOAA API
Attributes
@!attribute [r] id
@return [String] The unique Identifier
@!attribute [r] name
@return [String] The descriptive name
@!attribute [r] datacoverage
@return [Numeric] The estimated completeness of data, value between 0 and 1
@!attribute [r] mindate
@return [Date] Earliest availability of data with this type
@!attribute [r] maxdate
@return [String] Latest availability of data with this type
@!attribute [r] id
@return [String] The unique Identifier
@!attribute [r] name
@return [String] The descriptive name
@!attribute [r] datacoverage
@return [Numeric] The estimated completeness of data, value between 0 and 1
@!attribute [r] mindate
@return [Date] Earliest availability of data with this type
@!attribute [r] maxdate
@return [String] Latest availability of data with this type
@!attribute [r] id
@return [String] The unique Identifier
@!attribute [r] name
@return [String] The descriptive name
@!attribute [r] datacoverage
@return [Numeric] The estimated completeness of data, value between 0 and 1
@!attribute [r] mindate
@return [Date] Earliest availability of data with this type
@!attribute [r] maxdate
@return [String] Latest availability of data with this type
Public Class Methods
Finds a specific instance of {DataType} by its ID
@param id [String] String ID of the resource @return [DataCategory, nil] Instance of {DataCategory}, or nil if none found
# File lib/noaa_ncei_weather/data_type.rb, line 52 def self.find(id) data = super(@@endpoint + "/#{id}") if data && data.any? self.new data['id'], data['name'], data['datacoverage'], Date.parse(data['mindate']), Date.parse(data['maxdate']) else nil end end
Creates new {DataType} object
# File lib/noaa_ncei_weather/data_type.rb, line 22 def initialize(id, name, datacoverage, mindate, maxdate) super(id, name) @datacoverage = datacoverage @mindate = mindate @maxdate = maxdate end
Retrieves a set of {DataType DataTypes} 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] :datacategoryid String ID of a {DataCategory} @option params [DataCategory] :datacategory {DataCategory} object @option params [Date, String] :startdate Date or ISO formmated string to
restrict data types to those with data after this date
@option params [Date, String] :enddate Date or ISO formatted string to
restrict data types to those with data before this date
@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
# File lib/noaa_ncei_weather/data_type.rb, line 81 def self.where(params = {}) data = super(@@endpoint, params) if data && data.any? data.collect { |item| self.new item['id'], item['name'], item['datacoverage'], Date.parse(item['mindate']), Date.parse(item['maxdate']) } else [] end end
Public Instance Methods
Finds the {Dataset} that this instance of {DataType} belongs to. {Dataset} has a one to many relationship with {DataType}.
@return [Dataset] The {Dataset} object that this instance of {DataType} belongs to
# File lib/noaa_ncei_weather/data_type.rb, line 33 def dataset Dataset.where(datatypeid: @id).first end
Retrieves the {Station Stations} that are associated with this instance of {DataType}. {DataType} and {Station} have a many to many relationship
@param params [Hash] See {NoaaNceiWeather::Station.where} for valid key/values @return [Array<Station>] An Array of {Station} objects assocated with the
instance of {DataType}
# File lib/noaa_ncei_weather/data_type.rb, line 43 def stations(params = {}) params.merge!({datatypeid: @id}) Station.where(params) end