Class: GasLoadTester::ChartBuilder
- Inherits:
-
Object
- Object
- GasLoadTester::ChartBuilder
- Includes:
- Chartkick::Helper
- Defined in:
- lib/gas_load_tester/chart_builder.rb
Constant Summary collapse
- DEFAULT_PAGE_HEAD =
"<!DOCTYPE html>"\ "<html>"\ "<head>"\ "<script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>"\ "<script src=\"https://www.gstatic.com/charts/loader.js\"></script>"\ "<script src=\"https://ankane.github.io/chartkick.js/chartkick.js\"></script>"\ "</head>"\ "<body>"
- DEFAULT_PAGE_TAIL =
"<div style=\"display: block; height: 70px; width: 100%;\"></div>"\ "</body>"\ "</html>"
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Instance Method Summary collapse
- #build_body(test) ⇒ Object
- #build_group_body(group_test) ⇒ Object
-
#initialize(args = {}) ⇒ ChartBuilder
constructor
A new instance of ChartBuilder.
- #save ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ ChartBuilder
Returns a new instance of ChartBuilder.
23 24 25 26 27 |
# File 'lib/gas_load_tester/chart_builder.rb', line 23 def initialize(args = {}) args ||= {} args[:file_name] ||= args['file_name'] self.file_name = args[:file_name] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
8 9 10 |
# File 'lib/gas_load_tester/chart_builder.rb', line 8 def body @body end |
#file_name ⇒ Object
Returns the value of attribute file_name.
8 9 10 |
# File 'lib/gas_load_tester/chart_builder.rb', line 8 def file_name @file_name end |
Instance Method Details
#build_body(test) ⇒ Object
40 41 42 43 44 |
# File 'lib/gas_load_tester/chart_builder.rb', line 40 def build_body(test) sum_body = build_sum_test(test) self.body = DEFAULT_PAGE_HEAD + sum_body + DEFAULT_PAGE_TAIL end |
#build_group_body(group_test) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/gas_load_tester/chart_builder.rb', line 46 def build_group_body(group_test) sum_group_body = group_test.tests.collect{|test| build_sum_test(test) }.join('<hr style="margin-top: 70px; margin-bottom: 70px;">') sum_group_table = build_sum_group_table(group_test) self.body = DEFAULT_PAGE_HEAD + sum_group_table + sum_group_body + DEFAULT_PAGE_TAIL end |
#save ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gas_load_tester/chart_builder.rb', line 29 def save file_name = self.file_name if file_name == "" file_name = "load_result_"+Time.now.to_i.to_s+".html" elsif !file_name.end_with?(".html") file_name = file_name+".html" end File.open(file_name, 'w') { |file| file.write(self.body) } file_name end |