class FundRaise::FundRequest

Attributes

name[RW]
projects_ar[R]

Public Class Methods

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

Public Instance Methods

add_project(project) click to toggle source
# File lib/fund_raise/fund_request.rb, line 17
def add_project(project)
  @projects_ar.push(project)
end
load_projects(from_file) click to toggle source
# File lib/fund_raise/fund_request.rb, line 21
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/fund_raise/fund_request.rb, line 44
def request_funding(rounds)
  PledgePool::print_pledges_available
  puts "\nProject List #{@name}:"
  puts @projects_ar.sort
  
  1.upto(rounds) do |round|
    puts "\nRound #{round}:"
    @projects_ar.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/fund_raise/fund_request.rb, line 27
def save_underfunded_projects(to_file="underfunded_projects.txt")
  File.open(to_file, "w") do |file|
    file.puts "#{@name} Under-funded projects:"

    @projects_ar.sort.each do |p|
      if !p.fully_funded?
        file.puts underfunded_entry(p)
      end
    end
  end
end
to_s() click to toggle source
# File lib/fund_raise/fund_request.rb, line 96
def to_s
  "There are #{@projects_ar.size} projects in #{@name}."
end
total_pledges() click to toggle source
# File lib/fund_raise/fund_request.rb, line 59
def total_pledges
  @projects_ar.reduce(0) do |sum, project|
    sum + project.total_pledge_points
  end
end
underfunded_entry(project) click to toggle source
# File lib/fund_raise/fund_request.rb, line 39
def underfunded_entry(project)
  formatted_name = project.name.ljust(20, '.')
  "#{formatted_name} $#{project.funding_left} needed"
end