Class: SchedulesCSV

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SchedulesCSV

Returns a new instance of SchedulesCSV.



134
135
136
137
138
139
140
141
142
# File 'lib/energyplus/SchedulesCSV.rb', line 134

def initialize(path)
@schedules = Hash.new
  if File.exists?(path)
    @path = Pathname.new(path)
    process_schedules
  else
    @path = nil
  end
end

Instance Attribute Details

#schedulesObject

Returns the value of attribute schedules.



132
133
134
# File 'lib/energyplus/SchedulesCSV.rb', line 132

def schedules
  @schedules
end

Instance Method Details

#process_schedulesObject



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/energyplus/SchedulesCSV.rb', line 144

def process_schedules
  File.open(@path) do |f|
    name = ""
    schedule_string = ""
    while line = f.gets

      if line.chomp.empty?
        if not name.empty?
          new_schedule = Schedule.new(schedule_string)
          @schedules[new_schedule.name] = new_schedule
        end
        name = ""
        schedule_string = ""
        next
      end

      if name.empty?
        name = line.chomp
        schedule_string = line
      else
        schedule_string += line
      end
    end
  end
end