Class: EnergyPlus::IdfText

Inherits:
Object
  • Object
show all
Defined in:
lib/energyplus/IdfText.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ IdfText

Returns a new instance of IdfText.



22
23
24
25
26
27
28
29
30
31
32
# 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

Instance Method Details

#findObjectByComment(comment) ⇒ Object



60
61
62
63
64
65
66
67
68
# 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

#objectsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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