Class: UserDataCSV
- Inherits:
-
Object
- Object
- UserDataCSV
- Defined in:
- lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/ashrae_90_1_prm.UserData.rb
Direct Known Subclasses
UserDataCSVAirLoopHVAC, UserDataCSVAirLoopHVACDOAS, UserDataCSVBuilding, UserDataCSVElectricEquipment, UserDataCSVExteriorLights, UserDataCSVGasEquipment, UserDataCSVLights, UserDataCSVOutdoorAir, UserDataCSVSpace, UserDataCSVSpaceTypes, UserDataCSVThermalZone, UserDataCSVZoneHvac, UserDataWaterUseConnection, UserDataWaterUseEquipment, UserDataWaterUseEquipmentDefinition
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
getter function to get file name.
Instance Method Summary collapse
-
#initialize(model, save_dir) ⇒ UserDataCSV
constructor
Abstract class for writing user data template from user model.
-
#write_csv ⇒ Boolean
method to write csv files this method controls the workflow for generating a user data file.
Constructor Details
#initialize(model, save_dir) ⇒ UserDataCSV
Abstract class for writing user data template from user model.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/ashrae_90_1_prm.UserData.rb', line 6 def initialize(model, save_dir) @model = model @component_name = nil unless Dir.exist?(save_dir) raise ArgumentError "Saving directory #{save_dir} does not exist!" end @save_dir = save_dir @components = nil @headers = nil @file_name = nil end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
getter function to get file name
20 21 22 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/ashrae_90_1_prm.UserData.rb', line 20 def file_name @file_name end |
Instance Method Details
#write_csv ⇒ Boolean
method to write csv files this method controls the workflow for generating a user data file.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/openstudio-standards/standards/ashrae_90_1_prm/userdata_csv/ashrae_90_1_prm.UserData.rb', line 25 def write_csv @components = load_component @headers = load_header unless @components OpenStudio.logFree(OpenStudio::Warn, 'prm.log', "No relevant component #{@component_name} found in model. Skip the process") return false end CSV.open("#{@save_dir}/#{@file_name}.csv", 'w') do |csv| csv << @headers @components.each do |component| csv << ([prm_get_component_name(component)] + write_default_rows(component)) end end return true end |