Class: BTAP::Visualization::GraphEmbedder
- Inherits:
-
Object
- Object
- BTAP::Visualization::GraphEmbedder
- Defined in:
- lib/openstudio-standards/btap/visualization.rb
Constant Summary collapse
- Embedded_Definition_Start =
"var EMBEDDED_ARRAY = "
- Embedded_Function_Call =
"processEmbeddedArray(EMBEDDED_ARRAY);\n"
Class Method Summary collapse
-
.get_array_as_string(csv_file) ⇒ string_array<String>
This method will return an array as a string.
Instance Method Summary collapse
-
#create_embedding(csv_file) ⇒ Object
This method will create embedding.
-
#initialize(dest_file, html_file) ⇒ GraphEmbedder
constructor
This method sets the global parameters for the GraphicEmbedder destination file and html file.
Constructor Details
#initialize(dest_file, html_file) ⇒ GraphEmbedder
This method sets the global parameters for the GraphicEmbedder destination file and html file.
35 36 37 38 |
# File 'lib/openstudio-standards/btap/visualization.rb', line 35 def initialize(dest_file,html_file) @destination_file = dest_file @html_file = html_file end |
Class Method Details
.get_array_as_string(csv_file) ⇒ string_array<String>
This method will return an array as a string.
60 61 62 63 64 65 |
# 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 |
Instance Method Details
#create_embedding(csv_file) ⇒ Object
This method will create embedding.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/openstudio-standards/btap/visualization.rb', line 43 def (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 |