Class: BestCompanies::Company

Inherits:
Object
  • Object
show all
Defined in:
lib/best_companies/company.rb

Constant Summary collapse

@@all =
[]
@@archive =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(company_hash) ⇒ Company

Returns a new instance of Company.



6
7
8
9
10
11
12
13
# 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

Instance Attribute Details

#atmosphereObject

Returns the value of attribute atmosphere.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def atmosphere
  @atmosphere
end

#awardsObject

Returns the value of attribute awards.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def awards
  @awards
end

#bossesObject

Returns the value of attribute bosses.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def bosses
  @bosses
end

#challengesObject

Returns the value of attribute challenges.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def challenges
  @challenges
end

#communicationObject

Returns the value of attribute communication.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def communication
  @communication
end

#industryObject

Returns the value of attribute industry.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def industry
  @industry
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def location
  @location
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def name
  @name
end

#prideObject

Returns the value of attribute pride.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def pride
  @pride
end

#rankObject

Returns the value of attribute rank.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def rank
  @rank
end

#review_urlObject

Returns the value of attribute review_url.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def review_url
  @review_url
end

#rewardsObject

Returns the value of attribute rewards.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def rewards
  @rewards
end

#yearObject

Returns the value of attribute year.



2
3
4
# File 'lib/best_companies/company.rb', line 2

def year
  @year
end

Class Method Details

.allObject



15
16
17
# File 'lib/best_companies/company.rb', line 15

def self.all
 @@all
end

.archiveObject



50
51
52
53
54
55
56
# 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) ⇒ Object



19
20
21
22
23
# 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) ⇒ Object



58
59
60
61
# 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

Instance Method Details

#add_awards(awards_array) ⇒ Object



29
30
31
# File 'lib/best_companies/company.rb', line 29

def add_awards(awards_array)
 self.send("awards=",awards_array)
end

#add_ratings(ratings_hash) ⇒ Object



25
26
27
# File 'lib/best_companies/company.rb', line 25

def add_ratings(ratings_hash)
 ratings_hash.each{|key,value|self.send("#{key}=",value)}
end

#save?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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