Class: MatchingProject
- Inherits:
-
Pr::Project
- Object
- Pr::Project
- MatchingProject
- Defined in:
- lib/matching_project.rb
Instance Attribute Summary
Attributes inherited from Pr::Project
Instance Method Summary collapse
- #add_funds ⇒ Object
- #halfway_funded? ⇒ Boolean
-
#initialize(name, target_funding_amount, funding = 0) ⇒ MatchingProject
constructor
A new instance of MatchingProject.
Methods inherited from Pr::Project
#<=>, #each_received_pledge, from_csv, #pledges, #received_pledge, #time, #to_s, #total_funds
Methods included from Fundable
#fully_funded?, #got, #lost, #total_funding_outstanding
Constructor Details
#initialize(name, target_funding_amount, funding = 0) ⇒ MatchingProject
Returns a new instance of MatchingProject.
5 6 7 8 |
# File 'lib/matching_project.rb', line 5 def initialize(name, target_funding_amount, funding=0) super(name, target_funding_amount, funding) @halfway_funded = target_funding_amount / 2 end |
Instance Method Details
#add_funds ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/matching_project.rb', line 14 def add_funds if halfway_funded? @amount += (25*2) puts "#{@name} has received at least half its funding!" if halfway_funded? else super end end |
#halfway_funded? ⇒ Boolean
10 11 12 |
# File 'lib/matching_project.rb', line 10 def halfway_funded? @halfway_funded <= total_funds end |