class Schedule

Attributes

hours_per_year[RW]
name[RW]
table[RW]
type[RW]

Public Class Methods

new(s) click to toggle source
# File lib/energyplus/SchedulesCSV.rb, line 36
def initialize(s)
  @lines = s.split("\n")
  @name = make_schedule_name(@lines[0])
  @type = @lines[1]

  @table = Array.new
  this_table = Array.new
  duration = ""
  this_cols = 0
  open = false
  multi_duration = false
  (2..@lines.length-1).each do |idx|
    parts = CSV.parse_line(@lines[idx])

    if parts[0].include?('Through')
      if open
          if (not this_table[-1][0] == 'Total Hours/Year')
            this_table.push(Array.new)
            this_table[-1].push('Total Hours/Year') if not multi_duration
            (1..this_cols-1).each {|i| this_table[-1].push("") }
          end
          multi_duration = true
          close_table(this_table)
      end
      this_table = Array.new
      duration = parts[0]
      open = true

    elsif parts[0]==('Hour')
      this_table.push(Array.new)
      this_cols = parts.length
      this_table[-1].push(parts[0]) if not multi_duration
      (1..this_cols-1).each {|i| this_table[-1].push(parts[i] + " (" + duration + ")") }

    elsif parts[0].include?('Total Hours/Day')
      this_table.push(Array.new)
      this_table[-1].push(parts[0]) if not multi_duration
      (1..this_cols-1).each {|i| this_table[-1].push(custom_print(parts[i].to_f, 4)) }

    elsif parts[0].include?('Total Hours/Week')
      this_table.push(Array.new)
      this_table[-1].push(parts[0]) if not multi_duration
      this_table[-1].push(custom_print(parts[1].to_f, 4))
      (2..this_cols-1).each {|i| this_table[-1].push("") }

    elsif parts[0].include?('Total Hours/Year')
      @hours_per_year = parts[1].to_f

      this_table.push(Array.new)
      this_table[-1].push(parts[0]) if not multi_duration
      this_table[-1].push(custom_print(parts[1].to_f, 4))
      (2..this_cols-1).each {|i| this_table[-1].push("") }
    else
      parts.delete_at(0) if multi_duration
      this_table.push(parts)
    end
  end
  close_table(this_table)
  #print_table if multi_duration
end

Public Instance Methods

==(other) click to toggle source
# File lib/energyplus/SchedulesCSV.rb, line 122
def ==(other)
  eql?(other)
end
close_table(this_table) click to toggle source
# File lib/energyplus/SchedulesCSV.rb, line 97
def close_table(this_table)
  if @table.empty?
    @table = this_table
  else
    @table.each_index do |idx|
      @table[idx].concat(this_table[idx])
    end
  end
end
eql?(other) click to toggle source
# File lib/energyplus/SchedulesCSV.rb, line 125
def eql?(other)
  other.is_a?(Schedule) && to_s == other.to_s
end
hash() click to toggle source
# File lib/energyplus/SchedulesCSV.rb, line 119
def hash
  to_s.hash
end
print_table() click to toggle source
to_s() click to toggle source
# File lib/energyplus/SchedulesCSV.rb, line 116
def to_s
  @lines.join("\n")
end