class EnergyPlus::IdfText
Public Class Methods
new(path)
click to toggle source
# File lib/energyplus/IdfText.rb, line 22 def initialize(path) @path = path @lines = [] if @path.exist? File.open(@path) do |f| while line = f.gets @lines << line.chomp end end end end
Public Instance Methods
findObjectByComment(comment)
click to toggle source
# File lib/energyplus/IdfText.rb, line 60 def findObjectByComment(comment) comment = Regexp.new(comment) objects().each do |object| if object.comment =~ comment return object end end return nil end
objects()
click to toggle source
# File lib/energyplus/IdfText.rb, line 34 def objects objects = [] object_fields = [] object_type = '' inobject = false object_comment = nil @lines.each_index do |i| if not inobject and @lines[i] =~ /^\s*\w/ object_fields = [] inobject = true object_type = @lines[i] if @lines[i-1] =~ /^\s*!/ object_comment = @lines[i-1] end elsif inobject and @lines[i] =~ /^[^!]*;/ object_fields << @lines[i] inobject = false objects << IdfObject.new(object_type,object_fields,object_comment) elsif inobject object_fields << @lines[i] else end end return objects end