class EnergyPlus::EpErrFile

Public Class Methods

new(path) click to toggle source
# File lib/energyplus/EpErrFile.rb, line 24
def initialize(path)
  @path = path.expand_path
  @warnings = []
  @severe_errors = []
  @fatal_errors = []
  @initialized = false
  @successful = false
end

Public Instance Methods

dirname() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 64
def dirname
  @path.dirname
end
fatal_error_count() click to toggle source

the worst error

# File lib/energyplus/EpErrFile.rb, line 96
def fatal_error_count
    init if not initialized?
    @fatal_errors.size
end
fatal_errors() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 78
def fatal_errors
  init if not initialized?
  @fatal_errors
end
init() click to toggle source
# 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?() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 56
def initialized?
  @initialized
end
parse(id, text) click to toggle source

work horse

# 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() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 60
def path
  @path
end
severe_error_count() click to toggle source

severe errors are not as bad as fatal

# File lib/energyplus/EpErrFile.rb, line 90
def severe_error_count
    init if not initialized?
    @severe_errors.size
end
severe_errors() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 73
def severe_errors
  init if not initialized?
  @severe_errors
end
successful?() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 115
def successful?
  init if not initialized?
  @successful
end
valid?() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 51
def valid?
  init if not initialized?
  @valid
end
warning_count() click to toggle source

just a warning

# File lib/energyplus/EpErrFile.rb, line 84
def warning_count
  init if not initialized?
  warnings.size
end
warnings() click to toggle source
# File lib/energyplus/EpErrFile.rb, line 68
def warnings
  init if not initialized?
  @warnings
end