class BestCompanies::Company

Attributes

atmosphere[RW]
awards[RW]
bosses[RW]
challenges[RW]
communication[RW]
industry[RW]
location[RW]
name[RW]
pride[RW]
rank[RW]
review_url[RW]
rewards[RW]
year[RW]

Public Class Methods

all() click to toggle source
# File lib/best_companies/company.rb, line 15
def self.all
 @@all
end
archive() click to toggle source
# File lib/best_companies/company.rb, line 50
def self.archive
 if @@archive.size == 0
  puts "There is nothing in your archive"
 else
 @@archive.each{|company|BestCompanies::CLI.see_company(company)}
 end
end
create_from_list(company_hash) click to toggle source
# File lib/best_companies/company.rb, line 19
def self.create_from_list(company_hash)
 company_hash.each do |company|
 self.new(company)
 end
end
list_all(num1=0,num2=99) click to toggle source
# File lib/best_companies/company.rb, line 58
def self.list_all(num1=0,num2=99)
 puts "------------------------------------------------"
 self.all.slice(num1..num2).each{|company|BestCompanies::CLI.see_company(company)}
end
new(company_hash) click to toggle source
# File lib/best_companies/company.rb, line 6
def initialize(company_hash)
 company_hash.each do |key,value|
 self.send("#{key}=", value)
 end
 @@all << self
 BestCompanies::Industry.find_or_create_by_name(industry).add_company(self)
 BestCompanies::State.find_or_create_by_name(location.split(", ")[1]).add_company(self)
end

Public Instance Methods

add_awards(awards_array) click to toggle source
# File lib/best_companies/company.rb, line 29
def add_awards(awards_array)
 self.send("awards=",awards_array)
end
add_ratings(ratings_hash) click to toggle source
# File lib/best_companies/company.rb, line 25
def add_ratings(ratings_hash)
 ratings_hash.each{|key,value|self.send("#{key}=",value)}
end
save?() click to toggle source
# File lib/best_companies/company.rb, line 33
def save?
 puts "Would you like to save this company into your archives? Type y or n".colorize(:light_blue)
 input = gets.strip
 if input == "y" || input == "Y"
  if @@archive.include?(self)
   puts "This company is already saved in your archives."
  else
   @@archive << self
   puts "This company has been saved to your archives!".colorize(:light_blue)
   puts "------------------------------------------------"
  end
 else
  puts "You chose not to save this company".colorize(:light_blue)
  puts "------------------------------------------------"
 end
end