Class: TopCompanies::Company

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

Constant Summary collapse

@@all =
[]

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
# 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

#ceoObject

Returns the value of attribute ceo.



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

def ceo
  @ceo
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#sectorObject

Returns the value of attribute sector.



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

def sector
  @sector
end

#slugObject

Returns the value of attribute slug.



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

def slug
  @slug
end

#websiteObject

Returns the value of attribute website.



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

def website
  @website
end

Class Method Details

.allObject



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