Class: EnergyPlus::EpEsoFile
- Inherits:
-
Object
- Object
- EnergyPlus::EpEsoFile
- Defined in:
- lib/energyplus/EsoFile.rb
Instance Method Summary collapse
- #data ⇒ Object
- #dictionary ⇒ Object
- #dictionary_entries ⇒ Object
-
#initialize(path) ⇒ EpEsoFile
constructor
A new instance of EpEsoFile.
- #variables ⇒ Object
Constructor Details
#initialize(path) ⇒ EpEsoFile
Returns a new instance of EpEsoFile.
75 76 77 78 79 80 81 82 |
# File 'lib/energyplus/EsoFile.rb', line 75 def initialize(path) File.open(path) do |f| @variables = nil # first six lines are discarded 6.times {f.gets} @text = f.read end end |
Instance Method Details
#data ⇒ Object
88 89 90 |
# File 'lib/energyplus/EsoFile.rb', line 88 def data return @text.match(/(End\sof\sData\sDictionary)(.*?)(End\sof\sData)/m)[2] end |
#dictionary ⇒ Object
84 85 86 |
# File 'lib/energyplus/EsoFile.rb', line 84 def dictionary return @text.match(/(.*?)(End\sof\sData\sDictionary)/m)[1] end |
#dictionary_entries ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/energyplus/EsoFile.rb', line 92 def dictionary_entries dictionary_entries = [] dictionary.split("\n").each do |entry| interval = entry.match(/(!)(\w+)(\s*)/)[2].strip fields = entry.match(/(.*?)(!)/)[1].split(',') id = fields[0] key,var_name = fields[2,3] if fields[1] =~ /2/ key,var_name = nil, fields[2] if fields[1] =~ /1/ units = var_name.match(/(.*?)(\[)(.*?)(\])/)[3] var_name = $1.strip dictionary_entries << DictionaryEntry.new(id,key,var_name,units,interval) end return dictionary_entries end |
#variables ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/energyplus/EsoFile.rb', line 107 def variables unless @variables @variables = [] text = data dictionary_entries.each do |dictionary_entry| if dictionary_entry.interval =~ /Hourly/ = text.scan(/^2,.*?,\s0\.00,60\.00,.*/).map { |entry| entry.split(',') } elsif dictionary_entry.interval =~ /TimeStep/ = text.scan(/^2,.*/).reject { |entry| entry =~ /^2,.*?,\s0\.00,60\.00,.*/}.map { |entry| entry.split(',') } elsif dictionary_entry.interval =~ /Daily/ = text.scan(/^3,/).map { |entry| entry.split(',') } elsif dictionary_entry.interval =~ /Monthly/ = text.scan(/^4,/).map { |entry| entry.split(',') } end var_data = text.scan(Regexp.new("^#{dictionary_entry.id},.*")).map { |entry| entry.split(',') } @variables << Variable.new(dictionary_entry,var_data,) end end return @variables end |