Class: DailyMembershipReport::Row
- Inherits:
-
Object
- Object
- DailyMembershipReport::Row
- Defined in:
- app/models/daily_membership_report.rb
Instance Attribute Summary collapse
-
#details ⇒ Object
Returns the value of attribute details.
-
#id ⇒ Object
Returns the value of attribute id.
-
#membership ⇒ Object
Returns the value of attribute membership.
-
#order ⇒ Object
Returns the value of attribute order.
-
#person ⇒ Object
Returns the value of attribute person.
-
#person_id ⇒ Object
Returns the value of attribute person_id.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #calculate_total ⇒ Object
-
#initialize(items) ⇒ Row
constructor
A new instance of Row.
Constructor Details
#initialize(items) ⇒ Row
Returns a new instance of Row.
36 37 38 39 40 41 42 43 44 |
# File 'app/models/daily_membership_report.rb', line 36 def initialize(items) @order = items.first.order @id = items.first.order.id @membership = items.first.product.membership_type.name @quantity = items.length @total = DailyMembershipReport.number_to_currency(items.sum(&:price).to_f/100) @person = items.first.order.person @person_id = items.first.order.person.id end |
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def details @details end |
#id ⇒ Object
Returns the value of attribute id.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def id @id end |
#membership ⇒ Object
Returns the value of attribute membership.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def membership @membership end |
#order ⇒ Object
Returns the value of attribute order.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def order @order end |
#person ⇒ Object
Returns the value of attribute person.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def person @person end |
#person_id ⇒ Object
Returns the value of attribute person_id.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def person_id @person_id end |
#quantity ⇒ Object
Returns the value of attribute quantity.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def quantity @quantity end |
#total ⇒ Object
Returns the value of attribute total.
35 36 37 |
# File 'app/models/daily_membership_report.rb', line 35 def total @total end |
Instance Method Details
#calculate_total ⇒ Object
46 47 48 |
# File 'app/models/daily_membership_report.rb', line 46 def calculate_total DailyMembershipReport.number_to_currency(@order.memberships.sum(&:price).to_f/100) end |