Class: WeatherGov::Feature
- Inherits:
-
Object
- Object
- WeatherGov::Feature
show all
- Defined in:
- lib/weather_gov/feature.rb
Direct Known Subclasses
Alert, FeatureCollection, Forecast, Gridpoint, ObservationStation, Office, Point, Product, ProductList, RelativeLocation, Zone
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client:, data:) ⇒ Feature
Returns a new instance of Feature.
7
8
9
10
11
12
13
14
|
# File 'lib/weather_gov/feature.rb', line 7
def initialize(client:, data:)
@client = client
if data.respond_to?(:call)
@data_proc = data
else
@data = data
end
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/weather_gov/feature.rb', line 5
def client
@client
end
|
Instance Method Details
#context ⇒ Object
20
21
22
|
# File 'lib/weather_gov/feature.rb', line 20
def context
data.fetch("@context", nil)
end
|
#data ⇒ Object
16
17
18
|
# File 'lib/weather_gov/feature.rb', line 16
def data
@data ||= @data_proc.call
end
|
#geometry ⇒ Object
32
33
34
|
# File 'lib/weather_gov/feature.rb', line 32
def geometry
data.fetch("geometry", nil)
end
|
#id ⇒ Object
24
25
26
|
# File 'lib/weather_gov/feature.rb', line 24
def id
data.fetch("id")
end
|
#properties ⇒ Object
36
37
38
|
# File 'lib/weather_gov/feature.rb', line 36
def properties
data.fetch("properties", nil)
end
|
#type ⇒ Object
28
29
30
|
# File 'lib/weather_gov/feature.rb', line 28
def type
data.fetch("type")
end
|