Class: Renalware::HD::SessionPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Renalware::HD::SessionPresenter
show all
- Defined in:
- app/presenters/renalware/hd/session_presenter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(session, view_context = nil) ⇒ SessionPresenter
Returns a new instance of SessionPresenter.
32
33
34
35
36
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 32
def initialize(session, view_context = nil)
@view_context = view_context
@session = session
super(session)
end
|
Instance Attribute Details
#preference_set ⇒ Object
Returns the value of attribute preference_set.
6
7
8
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 6
def preference_set
@preference_set
end
|
Instance Method Details
#after_measurement_for(measurement) ⇒ Object
64
65
66
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 64
def after_measurement_for(measurement)
observations_after.try!(measurement.to_sym)
end
|
#before_measurement_for(measurement) ⇒ Object
60
61
62
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 60
def before_measurement_for(measurement)
observations_before.try(measurement.to_sym)
end
|
#change_in(measurement) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 68
def change_in(measurement)
pre = before_measurement_for(measurement)
post = after_measurement_for(measurement)
return if pre.blank? || post.blank?
case pre
when ::Float then (post - pre).round(1)
when ::Integer then (post - pre)
end
rescue StandardError => exception
nil
end
|
#edit_or_view_url ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 95
def edit_or_view_url
i18n_scope = "renalware.hd.sessions.#{session.state}"
if immutable?
view_context.link_to(I18n.t(".view", scope: i18n_scope),
view_context.patient_hd_session_path(patient, self),
class: "nowrap")
else
view_context.link_to(I18n.t(".edit", scope: i18n_scope),
view_context.edit_patient_hd_session_path(patient, self),
class: "nowrap")
end
end
|
#end_time ⇒ Object
52
53
54
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 52
def end_time
::I18n.l(super, format: :time)
end
|
42
43
44
45
46
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 42
def performed_on
url = view_context.patient_hd_session_path(session.patient, session)
text = ::I18n.l(super)
view_context.link_to(text, url)
end
|
#start_time ⇒ Object
48
49
50
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 48
def start_time
::I18n.l(super, format: :time)
end
|
#state ⇒ Object
38
39
40
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 38
def state
self.class.to_s.demodulize.downcase
end
|
#summarised_access_used ⇒ Object
#truncated_notes ⇒ Object
89
90
91
92
93
|
# File 'app/presenters/renalware/hd/session_presenter.rb', line 89
def truncated_notes
return unless notes
notes.truncate(100, omission: "…").html_safe
end
|