Class: Renalware::PD::DeliveryIntervalPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/renalware/pd/delivery_interval_presenter.rb

Class Method Summary collapse

Instance Method Summary collapse

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

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.dropdown_options
  PD.config.delivery_intervals.map do |duration|
    [duration.to_formatted_s, duration.iso8601]
  end
end

Instance Method Details

#to_sObject



12
13
14
# File 'app/presenters/renalware/pd/delivery_interval_presenter.rb', line 12

def to_s
  interval.to_formatted_s
end