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 27
def request_funding(rounds)
  PledgePool::print_pledges_available
  puts "Project List: #{@name}:"

  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_under_funded(to_file="under_funded.txt") click to toggle source
# File lib/fund_raise/fund_request.rb, line 41
def save_under_funded(to_file="under_funded.txt")
  File.open(to_file, "w") do |file|
    file.puts "#{@name}'s 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 86
def to_s
  "There are #{@projects_ar.size} projects in #{@name}." 
end
underfunded_entry(project) click to toggle source
# File lib/fund_raise/fund_request.rb, line 53
def underfunded_entry(project)
  formatted_name = project.name.ljust(20, '.')
  "#{formatted_name} $#{project.funding_left} needed"
end