class CrowdFund::FundRequest

Public Class Methods

new(project_name) click to toggle source
# File lib/fundraising_project/fundrequest.rb, line 8
def initialize(project_name)
  @project_name = project_name
  @projects = []
end

Public Instance Methods

add_project(project) click to toggle source
# File lib/fundraising_project/fundrequest.rb, line 12
def add_project(project)
  @projects << project
end
alter_funding(amount=25, rounds) click to toggle source
# File lib/fundraising_project/fundrequest.rb, line 59
def alter_funding(amount=25, rounds)
  puts "There are #{@projects.size} projects in the queue: "
  @projects.each do |project|
    puts project
  end
  puts "There are 3 possible pledge amounts:"
  pledges = PledgePool::PLEDGES
  pledges.each do |pledge|
    puts "A #{pledge.name} pledge is worth $#{pledge.amount}."
  end
  1.upto(rounds) do |n|
    puts "Round #{n}:\n"
    @projects.each do |project|
      FundingRound.randomize_funds(project, amount)
      FundingRound.random_pledge(project)
      puts project
    end
  end
end
load_projects(from_file) click to toggle source
# File lib/fundraising_project/fundrequest.rb, line 15
def load_projects(from_file)
  CSV.foreach(from_file) do |row|
    add_project(Project.new(row[0], row[1].to_i, row[2].to_i))
  end
end
print_funding_summary(method, to_file="funding_needed.csv") click to toggle source
print_funds_needs(project) click to toggle source
print_stats() click to toggle source
save_projects(to_file) click to toggle source
# File lib/fundraising_project/fundrequest.rb, line 20
def save_projects(to_file)
  File.open(to_file, "w") do |file|
    file.puts
  end
end