class Fundraising::Project
Attributes
funding[RW]
funding_target[RW]
name[RW]
Public Class Methods
new(name, funding=1000, funding_target=10000)
click to toggle source
# File lib/fundraising/project.rb, line 10 def initialize(name, funding=1000, funding_target=10000) @name = name.capitalize @funding = funding @funding_target = funding_target @pledges = Hash.new(0) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/fundraising/project.rb, line 33 def <=> (other) funds_needed <=> other.funds_needed end
each_pledge() { |pledge| ... }
click to toggle source
# File lib/fundraising/project.rb, line 23 def each_pledge @pledges.each do |name, amount| yield Pledge.new(name, amount) end end
pledges(pledge)
click to toggle source
# File lib/fundraising/project.rb, line 17 def pledges(pledge) @pledges[pledge.name] += pledge.amount @funding += pledge.amount puts "#{name} received a #{pledge.name} pledge worth #{pledge.amount}!" end
to_s()
click to toggle source
# File lib/fundraising/project.rb, line 29 def to_s "Project: #{name}\tFunds needed: #{funds_needed}" end