class Fundraise::FundRequest

Attributes

name[RW]
projects[R]

Public Class Methods

new(startup) click to toggle source
# File lib/fundraise/fund_request.rb, line 12
def initialize (startup)
  @name = startup
  @projects = []
end

Public Instance Methods

add_project(project) click to toggle source
# File lib/fundraise/fund_request.rb, line 33
def add_project(project)
  @projects << project
end
load_projects(from_file) click to toggle source
# File lib/fundraise/fund_request.rb, line 38
def load_projects(from_file)
 File.readlines(from_file).each do |line|
  add_project(Project.from_csv(line))
 end
end
print_stats() click to toggle source
request_funding(rounds) click to toggle source
# File lib/fundraise/fund_request.rb, line 44
def request_funding(rounds)
   PledgePool::print_pledges_available
   puts "\nProject List #{@name}:"

   1.upto(rounds) do |round|
    puts "\nRound #{round}:"
    @projects.each do |project|
    puts project
    FundingRound.one_round(project)
    puts "#{project}\n\n"
    end
   end
 end
save_underfunded_projects(to_file="underfunded_projects.txt") click to toggle source
# File lib/fundraise/fund_request.rb, line 22
def save_underfunded_projects(to_file="underfunded_projects.txt")
 File.open(to_file, "w") do |file|
  file.puts "#{@name} Under-funded Projects:"
   @projects.sort.each do |project|
     if !project.fully_funded?
     file.puts underfunded_project_entry(project)
     end
  end
 end
end
to_s() click to toggle source
# File lib/fundraise/fund_request.rb, line 58
def to_s
  "There are #{@projects.size} in #{@name}."
end
total_pledges() click to toggle source
# File lib/fundraise/fund_request.rb, line 62
def total_pledges
  @projects.reduce(0) do |sum, project|
   sum + project.pledge_money
  end
end
underfunded_project_entry(project) click to toggle source
# File lib/fundraise/fund_request.rb, line 17
def underfunded_project_entry(project)
 formatted_name = project.name.ljust(20, '.')
 "#{formatted_name} #{project.funding_needed} needed"
end