Class: Renalware::PD::RegimeBag

Inherits:
ApplicationRecord show all
Extended by:
Enumerize
Defined in:
app/models/renalware/pd/regime_bag.rb

Instance Method Summary collapse

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, _options = {})
  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

#daysObject



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_weekObject



58
59
60
# File 'app/models/renalware/pd/regime_bag.rb', line 58

def days_per_week
  days.count(true)
end

#has_volume?Boolean

Returns:

  • (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_bagObject



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