Class: Renalware::PD::RegimeBag
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::PD::RegimeBag
- Extended by:
- Enumerize
- Defined in:
- app/models/renalware/pd/regime_bag.rb
Instance Method Summary collapse
- #days ⇒ Object
- #days_per_week ⇒ Object
- #has_volume? ⇒ Boolean
-
#initialize(attributes = nil, _options = {}) ⇒ RegimeBag
constructor
A new instance of RegimeBag.
- #weekly_total_glucose_ml_per_bag ⇒ Object
Constructor Details
#initialize(attributes = nil, _options = {}) ⇒ RegimeBag
Returns a new instance of RegimeBag.
32 33 34 35 36 37 38 |
# File 'app/models/renalware/pd/regime_bag.rb', line 32 def initialize(attributes = nil, = {}) super() # !! Rails5 upgrade was super Date::DAYNAME_SYMBOLS.each do |day| public_send(:"#{day}=", true) end self.attributes = attributes unless attributes.nil? end |
Instance Method Details
#days ⇒ Object
48 49 50 51 52 |
# File 'app/models/renalware/pd/regime_bag.rb', line 48 def days Date::DAYNAME_SYMBOLS.map do |day| public_send(day) end end |
#days_per_week ⇒ Object
58 59 60 |
# File 'app/models/renalware/pd/regime_bag.rb', line 58 def days_per_week days.count(true) end |
#has_volume? ⇒ Boolean
62 63 64 |
# File 'app/models/renalware/pd/regime_bag.rb', line 62 def has_volume? volume.to_i.nonzero? end |
#weekly_total_glucose_ml_per_bag ⇒ Object
54 55 56 |
# File 'app/models/renalware/pd/regime_bag.rb', line 54 def weekly_total_glucose_ml_per_bag days_per_week * volume end |