class URBANopt::Reporting::DefaultReports::Location
Location include all location information.
Public Class Methods
          new(hash = {})
          
          click to toggle source
          
        
        
        Location class initialize location attributes: :latitude_deg , :longitude_deg , :surface_elevation_ft , :weather_filename
- parameters:
- 
hash- Hash - A hash which may contain a deserialized location.
# File lib/urbanopt/reporting/default_reports/location.rb, line 25 def initialize(hash = {}) hash.delete_if { |k, v| v.nil? } hash = defaults.merge(hash) @latitude_deg = hash[:latitude_deg] @longitude_deg = hash[:longitude_deg] @surface_elevation_ft = hash[:surface_elevation_ft] @weather_filename = hash[:weather_filename] # initialize class variables @@validator and @@schema @@validator ||= Validator.new @@schema ||= @@validator.schema end
Public Instance Methods
          defaults()
          
          click to toggle source
          
        
        
        Assign default values if values does not exist
# File lib/urbanopt/reporting/default_reports/location.rb, line 63 def defaults hash = {} hash[:latitude_deg] = nil hash[:longitude_deg] = nil hash[:surface_elevation_ft] = nil hash[:weather_filename] = nil return hash end
          to_hash()
          
          click to toggle source
          
        
        
        Convert to a Hash equivalent for JSON serialization.
- 
Exclude attributes with nil values. 
- 
Validate location hash properties against schema. 
# File lib/urbanopt/reporting/default_reports/location.rb, line 45 def to_hash result = {} result[:latitude_deg] = @latitude_deg if @latitude_deg result[:longitude_deg] = @longitude_deg if @longitude_deg result[:surface_elevation_ft] = @surface_elevation_ft if @surface_elevation_ft result[:weather_filename] = @weather_filename if @weather_filename # validate location properties against schema if @@validator.validate(@@schema[:definitions][:Location][:properties], result).any? raise "end_uses properties does not match schema: #{@@validator.validate(@@schema[:definitions][:Location][:properties], result)}" end return result end