Class: WeatherGov::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/weather_gov/feature.rb

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

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/weather_gov/feature.rb', line 5

def client
  @client
end

Instance Method Details

#contextObject



20
21
22
# File 'lib/weather_gov/feature.rb', line 20

def context
  data.fetch("@context", nil)
end

#dataObject



16
17
18
# File 'lib/weather_gov/feature.rb', line 16

def data
  @data ||= @data_proc.call
end

#geometryObject



32
33
34
# File 'lib/weather_gov/feature.rb', line 32

def geometry
  data.fetch("geometry", nil)
end

#idObject



24
25
26
# File 'lib/weather_gov/feature.rb', line 24

def id
  data.fetch("id")
end

#propertiesObject



36
37
38
# File 'lib/weather_gov/feature.rb', line 36

def properties
  data.fetch("properties", nil)
end

#typeObject



28
29
30
# File 'lib/weather_gov/feature.rb', line 28

def type
  data.fetch("type")
end