Class: Sandy::Provider::ConEd::Report
- Inherits:
-
Object
- Object
- Sandy::Provider::ConEd::Report
- Includes:
- StormCenter
- Defined in:
- lib/sandy/providers/coned/report.rb
Instance Attribute Summary collapse
-
#areas ⇒ Object
readonly
Returns the value of attribute areas.
Instance Method Summary collapse
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #to_json(*a) ⇒ Object
Methods included from StormCenter
#recursive_fetch_areas, #sanitize_name
Methods included from Sandy::Provider::CoordinateCache
#cached_coordinates_for, #gps_data
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sandy/providers/coned/report.rb', line 7 def initialize raw_report = JSON.parse(HTTParty.get(coned_url)) area_hash = raw_report.fetch("file_data")["curr_custs_aff"]["areas"].first["areas"] @areas = recursive_fetch_areas( area_hash, ->(area) { area.fetch("areas", nil) } ) rescue raise LoadError, "ConEd response was not recognizable." end |
Instance Attribute Details
#areas ⇒ Object (readonly)
Returns the value of attribute areas.
5 6 7 |
# File 'lib/sandy/providers/coned/report.rb', line 5 def areas @areas end |
Instance Method Details
#to_json(*a) ⇒ Object
20 21 22 23 |
# File 'lib/sandy/providers/coned/report.rb', line 20 def to_json(*a) hash = {} { "areas" => @areas.map(&:to_json) } end |