class CrowdFund::Project
Attributes
current_funding_amount[RW]
name[RW]
pledges[R]
target_funding_amount[R]
Public Class Methods
new(name, current_funding_amount=0, target_funding_amount=1000)
click to toggle source
# File lib/fundraising_project/project.rb, line 11 def initialize(name, current_funding_amount=0, target_funding_amount=1000) @name = name @current_funding_amount = current_funding_amount @target_funding_amount = target_funding_amount @pledges = Hash.new(0) end
Public Instance Methods
each_pledge() { |pledge| ... }
click to toggle source
# File lib/fundraising_project/project.rb, line 34 def each_pledge @pledges.each do |name, amount| yield(Pledge.new(name, amount)) end end
funding_needed()
click to toggle source
# File lib/fundraising_project/project.rb, line 18 def funding_needed @target_funding_amount - total_funds end
to_s()
click to toggle source
# File lib/fundraising_project/project.rb, line 30 def to_s "Project #{@name} has $#{total_funds} in funding towards a goal of $#{@target_funding_amount}." end
total_funds()
click to toggle source
# File lib/fundraising_project/project.rb, line 26 def total_funds @current_funding_amount + total_pledges end
total_pledges()
click to toggle source
# File lib/fundraising_project/project.rb, line 22 def total_pledges @pledges.values.reduce(0) {|sum, value| sum + value} end