Class: Sandy::Provider::LIPA::Report

Inherits:
Object
  • Object
show all
Includes:
StormCenter
Defined in:
lib/sandy/providers/lipa/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StormCenter

#recursive_fetch_areas, #sanitize_name

Methods included from CoordinateCache

#cached_coordinates_for, #gps_data

Constructor Details

#initializeReport

Returns a new instance of Report.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sandy/providers/lipa/report.rb', line 8

def initialize
  raw_report = HTTParty.get(lipa_url, format: :xml)
  area_hash = raw_report.fetch("root").fetch("curr_custs_aff")["areas"]["area"]["areas"].first[1]
  
  @areas = recursive_fetch_areas(
    area_hash, 
    ->(area) { area.fetch("areas", {}).fetch("area", nil) } 
  )

rescue
  raise LoadError, "LIPA response was not recognizable."
end

Instance Attribute Details

#areasObject (readonly)

Returns the value of attribute areas.



6
7
8
# File 'lib/sandy/providers/lipa/report.rb', line 6

def areas
  @areas
end