Class: BestCompanies::Company
- Inherits:
-
Object
- Object
- BestCompanies::Company
- Defined in:
- lib/best_companies/company.rb
Constant Summary collapse
- @@all =
[]
- @@archive =
[]
Instance Attribute Summary collapse
-
#atmosphere ⇒ Object
Returns the value of attribute atmosphere.
-
#awards ⇒ Object
Returns the value of attribute awards.
-
#bosses ⇒ Object
Returns the value of attribute bosses.
-
#challenges ⇒ Object
Returns the value of attribute challenges.
-
#communication ⇒ Object
Returns the value of attribute communication.
-
#industry ⇒ Object
Returns the value of attribute industry.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pride ⇒ Object
Returns the value of attribute pride.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#review_url ⇒ Object
Returns the value of attribute review_url.
-
#rewards ⇒ Object
Returns the value of attribute rewards.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
- .all ⇒ Object
- .archive ⇒ Object
- .create_from_list(company_hash) ⇒ Object
- .list_all(num1 = 0, num2 = 99) ⇒ Object
Instance Method Summary collapse
- #add_awards(awards_array) ⇒ Object
- #add_ratings(ratings_hash) ⇒ Object
-
#initialize(company_hash) ⇒ Company
constructor
A new instance of Company.
- #save? ⇒ Boolean
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
#atmosphere ⇒ Object
Returns the value of attribute atmosphere.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def atmosphere @atmosphere end |
#awards ⇒ Object
Returns the value of attribute awards.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def awards @awards end |
#bosses ⇒ Object
Returns the value of attribute bosses.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def bosses @bosses end |
#challenges ⇒ Object
Returns the value of attribute challenges.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def challenges @challenges end |
#communication ⇒ Object
Returns the value of attribute communication.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def communication @communication end |
#industry ⇒ Object
Returns the value of attribute industry.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def industry @industry end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def name @name end |
#pride ⇒ Object
Returns the value of attribute pride.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def pride @pride end |
#rank ⇒ Object
Returns the value of attribute rank.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def rank @rank end |
#review_url ⇒ Object
Returns the value of attribute review_url.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def review_url @review_url end |
#rewards ⇒ Object
Returns the value of attribute rewards.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def rewards @rewards end |
#year ⇒ Object
Returns the value of attribute year.
2 3 4 |
# File 'lib/best_companies/company.rb', line 2 def year @year end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/best_companies/company.rb', line 15 def self.all @@all end |
.archive ⇒ Object
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 () .each{|key,value|self.send("#{key}=",value)} end |
#save? ⇒ 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 |