class BTAP::Visualization::GraphEmbedder

Constants

Embedded_Definition_Start
Embedded_Function_Call

Public Class Methods

get_array_as_string(csv_file) click to toggle source

This method will return an array as a string. @author phylroy.lopez@nrcan.gc.ca @param csv_file [String] path to csv file @return [string_array<String>]

# File lib/openstudio-standards/btap/visualization.rb, line 60
def self.get_array_as_string(csv_file)
  csv = CSV.open(csv_file,'r')
  string_array = csv.to_a.inspect
  string_array = string_array.sub(/nil/,"\"\"")
  return string_array
end
new(dest_file,html_file) click to toggle source

This method sets the global parameters for the GraphicEmbedder destination file and html file. @author phylroy.lopez@nrcan.gc.ca @param dest_file [String] sets the global parameters for the GraphicEmbedder destination file @param html_file [String] sets the global parameters for the GraphicEmbedder html file

# File lib/openstudio-standards/btap/visualization.rb, line 35
def initialize(dest_file,html_file)
  @destination_file = dest_file
  @html_file = html_file
end

Public Instance Methods

create_embedding(csv_file) click to toggle source

This method will create embedding. @author phylroy.lopez@nrcan.gc.ca @param csv_file [String] path to csv file

# File lib/openstudio-standards/btap/visualization.rb, line 43
def create_embedding(csv_file)
  newfile = File.open(@destination_file, 'w')
  File.open(@html_file,'r').each do |line|
    if line.include? "!!Ruby Anchor!!"
      newfile.write(Embedded_Definition_Start + GraphEmbedder.get_array_as_string(csv_file) + ";\n")
      newfile.write(Embedded_Function_Call)
    else
      newfile.write(line)
    end
  end
  newfile.close
end