Class: WeatherSage::Weather::Point
- Inherits:
-
BaseObject
- Object
- BaseObject
- WeatherSage::Weather::Point
- Defined in:
- lib/weather-sage/weather/point.rb
Overview
Thin wrapper around lat/long point in weather API.
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
Attributes inherited from BaseObject
Instance Method Summary collapse
-
#forecast ⇒ Object
Returns a weather forecast for this point.
-
#hourly_forecast ⇒ Object
Returns an hourly weather forecast for this point.
-
#initialize(ctx, x, y) ⇒ Point
constructor
Create a new Point object at the given longitude
xand latitudey. -
#properties ⇒ Object
Returns a hash of properties for this point.
-
#stations ⇒ Object
Returns a list of weather stations near this point.
Constructor Details
#initialize(ctx, x, y) ⇒ Point
Create a new Point object at the given longitude x and latitude y.
11 12 13 14 |
# File 'lib/weather-sage/weather/point.rb', line 11 def initialize(ctx, x, y) super(ctx) @x, @y = x, y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
5 6 7 |
# File 'lib/weather-sage/weather/point.rb', line 5 def x @x end |
Instance Method Details
#forecast ⇒ Object
Returns a weather forecast for this point.
42 43 44 |
# File 'lib/weather-sage/weather/point.rb', line 42 def forecast forecast_by_type('forecast') end |
#hourly_forecast ⇒ Object
Returns an hourly weather forecast for this point.
49 50 51 |
# File 'lib/weather-sage/weather/point.rb', line 49 def hourly_forecast forecast_by_type('forecastHourly') end |
#properties ⇒ Object
Returns a hash of properties for this point.
31 32 33 34 35 36 37 |
# File 'lib/weather-sage/weather/point.rb', line 31 def properties # build request path path = 'points/%2.4f%%2C%2.4f' % [@y, @x] # execute request, return properties get(path)['properties'] end |
#stations ⇒ Object
Returns a list of weather stations near this point.
19 20 21 22 23 24 25 26 |
# File 'lib/weather-sage/weather/point.rb', line 19 def stations # build request path path = 'points/%2.4f%%2C%2.4f/stations' % [@y, @x] get(path)['features'].map { |row| WeatherSage::Weather::Station.from_json(@ctx, row) } end |