Class: Renalware::PD::DeliveryIntervalPresenter
- Inherits:
-
Object
- Object
- Renalware::PD::DeliveryIntervalPresenter
- Defined in:
- app/presenters/renalware/pd/delivery_interval_presenter.rb
Class Method Summary collapse
-
.dropdown_options ⇒ Object
An array of delivery interval options derived from the PD configuration, and using an iso8601 representation of the duration (eg “P4W” for 4 weeks), e.g.
Instance Method Summary collapse
-
#initialize(duration) ⇒ DeliveryIntervalPresenter
constructor
A new instance of DeliveryIntervalPresenter.
- #to_s ⇒ Object
Constructor Details
#initialize(duration) ⇒ DeliveryIntervalPresenter
Returns a new instance of DeliveryIntervalPresenter.
8 9 10 |
# File 'app/presenters/renalware/pd/delivery_interval_presenter.rb', line 8 def initialize(duration) @interval = duration.present? ? parse_iso8601_duration(duration) : NullObject.instance end |
Class Method Details
.dropdown_options ⇒ Object
An array of delivery interval options derived from the PD configuration, and using an iso8601 representation of the duration (eg “P4W” for 4 weeks), e.g. [
[
"1 week", "P1W",
"1 year", "P1Y",
...
]
] Note use Duration#to_formatted_s when rendering out a duration anywhere in the app.
26 27 28 29 30 |
# File 'app/presenters/renalware/pd/delivery_interval_presenter.rb', line 26 def self. PD.config.delivery_intervals.map do |duration| [duration.to_formatted_s, duration.iso8601] end end |
Instance Method Details
#to_s ⇒ Object
12 13 14 |
# File 'app/presenters/renalware/pd/delivery_interval_presenter.rb', line 12 def to_s interval.to_formatted_s end |