Class: Presenters::QcReportPresenter
- Inherits:
-
Object
- Object
- Presenters::QcReportPresenter
- Defined in:
- app/models/presenters/qc_report_presenter.rb
Constant Summary collapse
- REPORT_IDENTITY =
'Sequencescape QC Report'
- VERSION =
'1.0.0'
- HEADER_FIELDS =
{ 'Study' => :study_name, 'Product' => :product_name, 'Criteria Version' => :criteria_version, 'Report Identifier' => :report_identifier, 'Generated on' => :created_date, 'Contents' => :new_or_all }.freeze
Instance Attribute Summary collapse
-
#qc_report ⇒ Object
readonly
Returns the value of attribute qc_report.
-
#queue_count ⇒ Object
readonly
Returns the value of attribute queue_count.
Instance Method Summary collapse
- #created_date ⇒ Object
- #criteria_version ⇒ Object
- #each_header ⇒ Object
- #filename ⇒ Object
-
#initialize(qc_report, queue_count = 0) ⇒ QcReportPresenter
constructor
A new instance of QcReportPresenter.
- #new_or_all ⇒ Object
- #product_name ⇒ Object
- #state ⇒ Object
- #state_description ⇒ Object
- #study_abbreviation ⇒ Object
- #study_name ⇒ Object
- #to_csv(io) ⇒ Object
Constructor Details
#initialize(qc_report, queue_count = 0) ⇒ QcReportPresenter
Returns a new instance of QcReportPresenter.
16 17 18 19 |
# File 'app/models/presenters/qc_report_presenter.rb', line 16 def initialize(qc_report, queue_count = 0) @qc_report = qc_report @queue_count = queue_count end |
Instance Attribute Details
#qc_report ⇒ Object (readonly)
Returns the value of attribute qc_report.
14 15 16 |
# File 'app/models/presenters/qc_report_presenter.rb', line 14 def qc_report @qc_report end |
#queue_count ⇒ Object (readonly)
Returns the value of attribute queue_count.
14 15 16 |
# File 'app/models/presenters/qc_report_presenter.rb', line 14 def queue_count @queue_count end |
Instance Method Details
#created_date ⇒ Object
49 50 51 |
# File 'app/models/presenters/qc_report_presenter.rb', line 49 def created_date qc_report.created_at.to_fs(:rfc822) end |
#criteria_version ⇒ Object
25 26 27 |
# File 'app/models/presenters/qc_report_presenter.rb', line 25 def criteria_version "#{qc_report.product_criteria.stage}_#{qc_report.product_criteria.version}" end |
#each_header ⇒ Object
68 69 70 |
# File 'app/models/presenters/qc_report_presenter.rb', line 68 def each_header HEADER_FIELDS.each { |field, lookup| yield [field, send(lookup)] } end |
#filename ⇒ Object
21 22 23 |
# File 'app/models/presenters/qc_report_presenter.rb', line 21 def filename "#{report_identifier}.csv" end |
#new_or_all ⇒ Object
45 46 47 |
# File 'app/models/presenters/qc_report_presenter.rb', line 45 def new_or_all qc_report.exclude_existing ? 'New samples' : 'All samples' end |
#product_name ⇒ Object
29 30 31 |
# File 'app/models/presenters/qc_report_presenter.rb', line 29 def product_name qc_report.product.name end |
#state ⇒ Object
41 42 43 |
# File 'app/models/presenters/qc_report_presenter.rb', line 41 def state qc_report.state.humanize end |
#state_description ⇒ Object
53 54 55 |
# File 'app/models/presenters/qc_report_presenter.rb', line 53 def state_description I18n.t(qc_report.state, scope: 'qc_reports.state_descriptions', default: :default, queue_count: queue_count) end |
#study_abbreviation ⇒ Object
37 38 39 |
# File 'app/models/presenters/qc_report_presenter.rb', line 37 def study_abbreviation qc_report.study.abbreviation end |
#study_name ⇒ Object
33 34 35 |
# File 'app/models/presenters/qc_report_presenter.rb', line 33 def study_name qc_report.study.name end |
#to_csv(io) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'app/models/presenters/qc_report_presenter.rb', line 57 def to_csv(io) @csv = CSV.new(io) csv_headers @csv << [] # Pad with an empty line csv_field_headers csv_body @csv end |