Class: NDFD::Client::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/ndfd/client/query.rb

Constant Summary collapse

FORECAST_ELEMENTS =
{
  :maxt         => "Maximum Temperature",
  :mint         => "Minimum Temperature",
  :temp         => "3 Hourly Temperature",
  :dew          => "Dewpoint Temperature",
  :appt         => "Apparent Temperature",
  :pop12        => "12 Hour Probability of Precipitation",
  :qpf          => "Liquid Precipitation Amount",
  :snow         => "Snowfall Amount",
  :sky          => "Cloud Cover Amount",
  :rh           => "Relative Humidity",
  :wspd         => "Wind Speed",
  :wdir         => "Wind Direction",
  :wx           => "Weather",
  :icons        => "Weather Icons",
  :waveh        => "Wave Height",
  :incw34       => "Probabilistic Tropical Cyclone Wind Speed >34 Knots (Incremental)",
  :incw50       => "Probabilistic Tropical Cyclone Wind Speed >50 Knots (Incremental)",
  :incw64       => "Probabilistic Tropical Cyclone Wind Speed >64 Knots (Incremental)",
  :cumw34       => "Probabilistic Tropical Cyclone Wind Speed >34 Knots (Cumulative)",
  :cumw50       => "Probabilistic Tropical Cyclone Wind Speed >50 Knots (Cumulative)",
  :cumw64       => "Probabilistic Tropical Cyclone Wind Speed >64 Knots (Cumulative)",
  :wgust        => "Wind Gust",
  :critfireo    => "Fire Weather from Wind and Relative Humidity",
  :dryfireo     => "Fire Weather from Dry Thunderstorms",
  :conhazo      => "Convective Hazard Outlook",
  :ptornado     => "Probability of Tornadoes",
  :phail        => "Probability of Hail",
  :ptstmwinds   => "Probability of Damaging Thunderstorm Winds",
  :pxtornado    => "Probability of Extreme Tornadoes",
  :pxhail       => "Probability of Extreme Hail",
  :pxtstmwinds  => "Probability of Extreme Thunderstorm Winds",
  :ptotsvrtstm  => "Probability of Severe Thunderstorms",
  :pxtotsvrtstm => "Probability of Extreme Severe Thunderstorms",
  :tmpabv14d    => "Probability of 8- To 14-Day Average Temperature Above Normal",
  :tmpblw14d    => "Probability of 8- To 14-Day Average Temperature Below Normal",
  :tmpabv30d    => "Probability of One-Month Average Temperature Above Normal",
  :tmpblw30d    => "Probability of One-Month Average Temperature Below Normal",
  :tmpabv90d    => "Probability of Three-Month Average Temperature Above Normal",
  :tmpblw90d    => "Probability of Three-Month Average Temperature Below Normal",
  :prcpabv14d   => "Probability of 8- To 14-Day Total Precipitation Above Median",
  :prcpblw14d   => "Probability of 8- To 14-Day Total Precipitation Below Median",
  :prcpabv30d   => "Probability of One-Month Total Precipitation Above Median",
  :prcpblw30d   => "Probability of One-Month Total Precipitation Below Median",
  :prcpabv90d   => "Probability of Three-Month Total Precipitation Above Median",
  :prcpblw90d   => "Probability of Three-Month Total Precipitation Below Median",
  :precipa_r    => "Real-time Mesoscale Analysis Precipitation",
  :sky_r        => "Real-time Mesoscale Analysis GOES Effective Cloud Amount",
  :td_r         => "Real-time Mesoscale Analysis Dewpoint Temperature",
  :temp_r       => "Real-time Mesoscale Analysis Temperature",
  :wdir_r       => "Real-time Mesoscale Analysis Wind Direction",
  :wspd_r       => "Real-time Mesoscale Analysis Wind Speed",
  :wwa          => "Watches, Warnings, and Advisories",
  :iceaccum     => "Ice Accumulation",
  :maxrh        => "Maximum Relative Humidity",
  :minrh        => "Minimum Relative Humidity"
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(soap_client, select_attributes = []) ⇒ Query


73
74
75
76
77
# File 'lib/ndfd/client/query.rb', line 73

def initialize(soap_client, select_attributes = [])
  @soap_client = soap_client
  @select_attributes = select_attributes
  @conditions = {}
end

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions


71
72
73
# File 'lib/ndfd/client/query.rb', line 71

def conditions
  @conditions
end

#select_attributesObject (readonly)

Returns the value of attribute select_attributes


71
72
73
# File 'lib/ndfd/client/query.rb', line 71

def select_attributes
  @select_attributes
end

#soap_clientObject (readonly)

Returns the value of attribute soap_client


71
72
73
# File 'lib/ndfd/client/query.rb', line 71

def soap_client
  @soap_client
end

Class Method Details

.propertiesObject


96
97
98
# File 'lib/ndfd/client/query.rb', line 96

def properties
  @@properties ||= {}
end

.property(attr, options = {}) ⇒ Object


100
101
102
103
# File 'lib/ndfd/client/query.rb', line 100

def property(attr, options = {})
  properties[self] ||= []
  properties[self] << QueryProperty.new(attr, options)
end

.selection_attributesObject


105
106
107
# File 'lib/ndfd/client/query.rb', line 105

def selection_attributes
  @@selection_attributes ||= {}
end

.set_selection_attributes(*attrs) ⇒ Object


109
110
111
# File 'lib/ndfd/client/query.rb', line 109

def set_selection_attributes(*attrs)
  selection_attributes[self] = SelectionAttributes.new(attrs)
end

Instance Method Details

#executeObject

Raises:

  • (NotImplementedError)

86
87
88
# File 'lib/ndfd/client/query.rb', line 86

def execute
  raise NotImplementedError, "Must be implemented in subclass."
end

#validateObject


90
91
92
93
# File 'lib/ndfd/client/query.rb', line 90

def validate
  validate_selection_attributes
  validate_conditions
end

#where(params) ⇒ Object


79
80
81
82
83
84
# File 'lib/ndfd/client/query.rb', line 79

def where(params)
  conditions.merge!(params)
  set_defaults_as_needed

  self
end