Class: NDBC::Station
- Inherits:
-
Object
- Object
- NDBC::Station
- Includes:
- StationTable
- Defined in:
- lib/ndbc/station.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
(also: #active?)
readonly
Returns the value of attribute active.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#forecast ⇒ Object
readonly
Returns the value of attribute forecast.
-
#hull ⇒ Object
readonly
Returns the value of attribute hull.
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#tide_station_id ⇒ Object
readonly
Returns the value of attribute tide_station_id.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#ttype ⇒ Object
readonly
Returns the value of attribute ttype.
Class Method Summary collapse
Instance Method Summary collapse
- #continuous_winds_data ⇒ Object
-
#initialize(id, station_data = {}) ⇒ Station
constructor
A new instance of Station.
- #inspect ⇒ Object
- #latest_continuous_winds_data ⇒ Object
- #latest_spectral_wave_forecasts ⇒ Object
- #latest_spectral_wave_summaries ⇒ Object
- #latest_standard_meteorological_data ⇒ Object
- #method_missing(method_sym, *arguments, &block) ⇒ Object
- #respond_to_missing?(method_sym, include_private = false) ⇒ Boolean
- #spectral_wave_forecasts ⇒ Object
- #spectral_wave_summaries ⇒ Object
- #standard_meteorological_data ⇒ Object
Methods included from StationTable
Constructor Details
#initialize(id, station_data = {}) ⇒ Station
Returns a new instance of Station.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ndbc/station.rb', line 20 def initialize(id, station_data = {}) @id = id.to_s @owner = station_data[:owner] @ttype = station_data[:ttype] @hull = station_data[:hull] @name = station_data[:name] @payload = station_data[:payload] @location = station_data[:location] @timezone = station_data[:timezone] @forecast = station_data[:forecast] @note = station_data[:note] @active = station_data[:active] @tide_station_id = station_data[:tide_station_id] @connection = Connection.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ndbc/station.rb', line 80 def method_missing(method_sym, *arguments, &block) upcased_method_name = method_sym.to_s.upcase case method_sym when :wdir, :wspd, :gst, :wvht, :dpd, :apd, :mwd, :pres, :atmp, :wtmp, :dewp, :vis, :ptdy, :tide latest_standard_meteorological_data[upcased_method_name] when :dir, :spd, :gdr, :gsp, :gtime latest_continuous_winds_data[upcased_method_name] when :h0, :wwh, :wwp, :wwd, :steepness, :avp latest_spectral_wave_summaries[upcased_method_name] when :swh latest_spectral_wave_summaries['SwH'] when :swp latest_spectral_wave_summaries['SwP'] when :swd latest_spectral_wave_summaries['SwD'] else super end end |
Instance Attribute Details
#active ⇒ Object (readonly) Also known as: active?
Returns the value of attribute active.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def active @active end |
#connection ⇒ Object
Returns the value of attribute connection.
14 15 16 |
# File 'lib/ndbc/station.rb', line 14 def connection @connection end |
#forecast ⇒ Object (readonly)
Returns the value of attribute forecast.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def forecast @forecast end |
#hull ⇒ Object (readonly)
Returns the value of attribute hull.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def hull @hull end |
#id ⇒ Object
Returns the value of attribute id.
14 15 16 |
# File 'lib/ndbc/station.rb', line 14 def id @id end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def name @name end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def note @note end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def owner @owner end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def payload @payload end |
#tide_station_id ⇒ Object (readonly)
Returns the value of attribute tide_station_id.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def tide_station_id @tide_station_id end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def timezone @timezone end |
#ttype ⇒ Object (readonly)
Returns the value of attribute ttype.
15 16 17 |
# File 'lib/ndbc/station.rb', line 15 def ttype @ttype end |
Class Method Details
.all ⇒ Object
9 10 11 |
# File 'lib/ndbc/station.rb', line 9 def all NDBC::StationTable.station_table_data.map { |data| new(data[:id].upcase, data) } end |
Instance Method Details
#continuous_winds_data ⇒ Object
50 51 52 53 54 |
# File 'lib/ndbc/station.rb', line 50 def continuous_winds_data @continuous_winds_data ||= parse_observation_response( get_data(NDBC.config[:urls][:observations] + id + ".cwind") ) end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/ndbc/station.rb', line 36 def inspect "#{id} (lat: #{@location[:latitude]}, lon: #{@location[:longitude]})" end |
#latest_continuous_winds_data ⇒ Object
56 57 58 |
# File 'lib/ndbc/station.rb', line 56 def latest_continuous_winds_data latest_data(:continuous_winds_data) end |
#latest_spectral_wave_forecasts ⇒ Object
76 77 78 |
# File 'lib/ndbc/station.rb', line 76 def latest_spectral_wave_forecasts latest_data(:spectral_wave_forecasts) end |
#latest_spectral_wave_summaries ⇒ Object
66 67 68 |
# File 'lib/ndbc/station.rb', line 66 def latest_spectral_wave_summaries latest_data(:spectral_wave_summaries) end |
#latest_standard_meteorological_data ⇒ Object
46 47 48 |
# File 'lib/ndbc/station.rb', line 46 def latest_standard_meteorological_data latest_data(:standard_meteorological_data) end |
#respond_to_missing?(method_sym, include_private = false) ⇒ Boolean
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ndbc/station.rb', line 101 def respond_to_missing?(method_sym, include_private = false) case method_sym when :wdir, :wspd, :gst, :wvht, :dpd, :apd, :mwd, :pres, :atmp, :wtmp, :dewp, :vis, :ptdy, :tide, :dir, :spd, :gdr, :gsp, :gtime, :h0, :wwh, :wwp, :wwd, :steepness, :avp, :swh, :swp, :swd, :swd true else super end end |
#spectral_wave_forecasts ⇒ Object
70 71 72 73 74 |
# File 'lib/ndbc/station.rb', line 70 def spectral_wave_forecasts @spectral_wave_forecasts ||= parse_prediction_response( get_data(NDBC.config[:urls][:predictions] + "multi_1.#{id}.bull") ) end |