Class: HealthcarePhony::CsvFile
- Inherits:
-
Object
- Object
- HealthcarePhony::CsvFile
- Defined in:
- lib/healthcare_phony.rb
Instance Attribute Summary collapse
-
#number_of_rows ⇒ Object
readonly
Returns the value of attribute number_of_rows.
-
#template_file ⇒ Object
readonly
Returns the value of attribute template_file.
Instance Method Summary collapse
-
#initialize(number_of_rows, template_file = nil) ⇒ CsvFile
constructor
A new instance of CsvFile.
- #to_s ⇒ Object
Constructor Details
#initialize(number_of_rows, template_file = nil) ⇒ CsvFile
Returns a new instance of CsvFile.
42 43 44 45 46 47 48 49 |
# File 'lib/healthcare_phony.rb', line 42 def initialize(number_of_rows, template_file = nil) @template_file = if template_file.nil? File.join(File.dirname(__FILE__), 'healthcare_phony', 'templates', 'csv_example.erb') else template_file end @number_of_rows = number_of_rows end |
Instance Attribute Details
#number_of_rows ⇒ Object (readonly)
Returns the value of attribute number_of_rows.
40 41 42 |
# File 'lib/healthcare_phony.rb', line 40 def number_of_rows @number_of_rows end |
#template_file ⇒ Object (readonly)
Returns the value of attribute template_file.
40 41 42 |
# File 'lib/healthcare_phony.rb', line 40 def template_file @template_file end |
Instance Method Details
#to_s ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/healthcare_phony.rb', line 51 def to_s template = ERB.new(File.read(@template_file), trim_mode: '<>') counter = 0 output_string = '' while counter < @number_of_rows output_string += "#{template.result_with_hash({ patient: Patient.new, write_header: counter.zero? })}\n" counter += 1 end output_string end |