Class: TopCompanies::Company
- Inherits:
-
Object
- Object
- TopCompanies::Company
- Defined in:
- lib/top_companies/company.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#ceo ⇒ Object
Returns the value of attribute ceo.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sector ⇒ Object
Returns the value of attribute sector.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #add_attributes(company_hash) ⇒ Object
-
#initialize(company_hash) ⇒ Company
constructor
A new instance of Company.
Constructor Details
#initialize(company_hash) ⇒ Company
Returns a new instance of Company.
6 7 8 9 10 11 |
# File 'lib/top_companies/company.rb', line 6 def initialize(company_hash) company_hash.each do |attribute, value| self.send("#{attribute}=", value) end @@all << self end |
Instance Attribute Details
#ceo ⇒ Object
Returns the value of attribute ceo.
2 3 4 |
# File 'lib/top_companies/company.rb', line 2 def ceo @ceo end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/top_companies/company.rb', line 2 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/top_companies/company.rb', line 2 def name @name end |
#sector ⇒ Object
Returns the value of attribute sector.
2 3 4 |
# File 'lib/top_companies/company.rb', line 2 def sector @sector end |
#slug ⇒ Object
Returns the value of attribute slug.
2 3 4 |
# File 'lib/top_companies/company.rb', line 2 def slug @slug end |
#website ⇒ Object
Returns the value of attribute website.
2 3 4 |
# File 'lib/top_companies/company.rb', line 2 def website @website end |
Class Method Details
.all ⇒ Object
25 26 27 |
# File 'lib/top_companies/company.rb', line 25 def self.all @@all end |
.create_from_collection(companies_array) ⇒ Object
13 14 15 16 17 |
# File 'lib/top_companies/company.rb', line 13 def self.create_from_collection(companies_array) companies_array.each do |company_hash| TopCompanies::Company.new(company_hash) end end |
Instance Method Details
#add_attributes(company_hash) ⇒ Object
19 20 21 22 23 |
# File 'lib/top_companies/company.rb', line 19 def add_attributes(company_hash) company_hash.each do |attribute, value| self.send("#{attribute}=", value) end end |