Class: EnergyPlus::EpErrFile
- Inherits:
-
Object
- Object
- EnergyPlus::EpErrFile
- Defined in:
- lib/energyplus/EpErrFile.rb
Instance Method Summary collapse
- #dirname ⇒ Object
-
#fatal_error_count ⇒ Object
the worst error.
- #fatal_errors ⇒ Object
- #init ⇒ Object
-
#initialize(path) ⇒ EpErrFile
constructor
A new instance of EpErrFile.
- #initialized? ⇒ Boolean
-
#parse(id, text) ⇒ Object
work horse.
- #path ⇒ Object
-
#severe_error_count ⇒ Object
severe errors are not as bad as fatal.
- #severe_errors ⇒ Object
- #successful? ⇒ Boolean
- #valid? ⇒ Boolean
-
#warning_count ⇒ Object
just a warning.
- #warnings ⇒ Object
Constructor Details
#initialize(path) ⇒ EpErrFile
Returns a new instance of EpErrFile.
24 25 26 27 28 29 30 31 |
# File 'lib/energyplus/EpErrFile.rb', line 24 def initialize(path) @path = path. @warnings = [] @severe_errors = [] @fatal_errors = [] @initialized = false @successful = false end |
Instance Method Details
#dirname ⇒ Object
64 65 66 |
# File 'lib/energyplus/EpErrFile.rb', line 64 def dirname @path.dirname end |
#fatal_error_count ⇒ Object
the worst error
96 97 98 99 |
# File 'lib/energyplus/EpErrFile.rb', line 96 def fatal_error_count init if not initialized? @fatal_errors.size end |
#fatal_errors ⇒ Object
78 79 80 81 |
# File 'lib/energyplus/EpErrFile.rb', line 78 def fatal_errors init if not initialized? @fatal_errors end |
#init ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/energyplus/EpErrFile.rb', line 33 def init @initialized = true if @path.exist? File.open(@path) do |f| text = '' text << f.read @valid = true @warnings = parse("Warning", text) @severe_errors = parse("Severe", text) @fatal_errors = parse("Fatal", text) if text =~ /\s\*{13} EnergyPlus Completed Successfully/ @successful = true end end end end |
#initialized? ⇒ Boolean
56 57 58 |
# File 'lib/energyplus/EpErrFile.rb', line 56 def initialized? @initialized end |
#parse(id, text) ⇒ Object
work horse
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/energyplus/EpErrFile.rb', line 102 def parse(id, text) storage = [] this_text = text # match first id label and continue matching across lines while seeing the continue label "** ~~~ **" regex = /\*\*\s*#{id}\s*\*\*.*?\n(\s+\*\*\s\s\s~~~\s\s\s\*\*.*?\n)*/m while match_data = this_text.match(regex) this_string = match_data.to_s.gsub(/.*\*\*\s*#{id}\s*\*\*/, '').gsub(/.*\*\*\s\s\s~~~\s\s\s\*\*/, '').gsub(/\s*\n/, "\n") storage.push(this_string) this_text = match_data.post_match end return storage.uniq end |
#path ⇒ Object
60 61 62 |
# File 'lib/energyplus/EpErrFile.rb', line 60 def path @path end |
#severe_error_count ⇒ Object
severe errors are not as bad as fatal
90 91 92 93 |
# File 'lib/energyplus/EpErrFile.rb', line 90 def severe_error_count init if not initialized? @severe_errors.size end |
#severe_errors ⇒ Object
73 74 75 76 |
# File 'lib/energyplus/EpErrFile.rb', line 73 def severe_errors init if not initialized? @severe_errors end |
#successful? ⇒ Boolean
115 116 117 118 |
# File 'lib/energyplus/EpErrFile.rb', line 115 def successful? init if not initialized? @successful end |
#valid? ⇒ Boolean
51 52 53 54 |
# File 'lib/energyplus/EpErrFile.rb', line 51 def valid? init if not initialized? @valid end |
#warning_count ⇒ Object
just a warning
84 85 86 87 |
# File 'lib/energyplus/EpErrFile.rb', line 84 def warning_count init if not initialized? warnings.size end |
#warnings ⇒ Object
68 69 70 71 |
# File 'lib/energyplus/EpErrFile.rb', line 68 def warnings init if not initialized? @warnings end |