Class: Crowdfunder::MatchingFundProject

Inherits:
Project
  • Object
show all
Defined in:
lib/crowdfunder/matching_fund_project.rb

Instance Attribute Summary

Attributes inherited from Project

#fully_funded, #initial_fund, #name, #target_fund

Instance Method Summary collapse

Methods inherited from Project

#each_pledge_received, #found_pledge, #pledged_funds, #to_s, #total_funds

Methods included from Fundable

#<=>, #fully_funded?, #remove_funds, #total_funding_outstanding, #total_required_funds

Constructor Details

#initialize(name, initial_fund, target_fund) ⇒ MatchingFundProject

Returns a new instance of MatchingFundProject.



6
7
8
9
# File 'lib/crowdfunder/matching_fund_project.rb', line 6

def initialize(name, initial_fund, target_fund)
  super(name, initial_fund, target_fund)
  @half_funds_raised  = target_fund / 2.0
end

Instance Method Details

#add_fundsObject



15
16
17
18
19
20
21
22
23
# File 'lib/crowdfunder/matching_fund_project.rb', line 15

def add_funds
  if half_funded?
    @initial_fund += (25 * 2)
    puts "#{name} is match ready!"
    puts "#{name} got double funds. Total funds: #{total_funds}"
  else
    super
  end
end

#half_funded?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/crowdfunder/matching_fund_project.rb', line 11

def half_funded?
  total_funds >= @half_funds_raised   #<= initial_fund
end