Class: NoaaNceiWeather::Weather Abstract

Inherits:
Object
  • Object
show all
Extended by:
Connection
Defined in:
lib/noaa_ncei_weather/weather.rb

Overview

This class is abstract.

Superclass to all of the resource classes used to help filter data queried using Data

Instance Attribute Summary collapse

Attributes included from Connection

#token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Connection

parse_params, request, token=, where

Constructor Details

#initialize(id, name) ⇒ Weather

Creates a new Weather object



15
16
17
18
# File 'lib/noaa_ncei_weather/weather.rb', line 15

def initialize(id, name)
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



12
# File 'lib/noaa_ncei_weather/weather.rb', line 12

attr_reader :name, :id

#nameString (readonly)

Returns The descriptive name of the resource.

Returns:

  • (String)

    The descriptive name of the resource



12
13
14
# File 'lib/noaa_ncei_weather/weather.rb', line 12

def name
  @name
end

Class Method Details

.allArray<Weather>

Used to query for all the resources without any filter

Returns:

  • (Array<Weather>)

    Returns an array of objects, whichever type is being queried



23
24
25
# File 'lib/noaa_ncei_weather/weather.rb', line 23

def self.all
  self.where
end

.find(endpoint) ⇒ Object

Used to query for a single ID



28
29
30
# File 'lib/noaa_ncei_weather/weather.rb', line 28

def self.find(endpoint)
  self.request(endpoint)
end

.firstObject

Used to retrieve a single record with no specification



33
34
35
# File 'lib/noaa_ncei_weather/weather.rb', line 33

def self.first
  self.where(limit: 1).first
end