Created
November 4, 2012 17:25
-
-
Save ckundo/4012674 to your computer and use it in GitHub Desktop.
stormpox.com - Coned class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Coned | |
| BOROS = ["Bronx" "Brooklyn", "Manhattan", "Queens", "Staten Island", "Westchester"] | |
| def initialize | |
| @response = HTTParty.get(coned_url_with_directory, :format => :json).parsed_response | |
| @report = Report.new | |
| end | |
| def populate_worksheet | |
| @report.update_worksheet(worksheet_data) | |
| end | |
| private | |
| def worksheet_data | |
| current_time = Time.now.strftime("%m/%d/%Y %H:%M:%S") | |
| [current_time] + areas.collect { |area| area["custs_out"] || ""} | |
| end | |
| def areas | |
| @response["file_data"]["curr_custs_aff"]["areas"][0]["areas"] | |
| end | |
| def coned_url_with_directory | |
| base_uri = "http://apps.coned.com" | |
| directory = HTTParty.get("#{base_uri}/stormcenter_external/stormcenter_externaldata/data/interval_generation_data/metadata.xml", :format => :xml).parsed_response['root']['directory'] | |
| url = "#{base_uri}/stormcenter_external/stormcenter_externaldata/data/interval_generation_data/#{directory}/report.js" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment