Class: StocktickerCli::STOCK

Inherits:
Object
  • Object
show all
Defined in:
lib/stockticker_cli/stock.rb

Overview

“symbol”=>“PAYX”, “name”=>“Paychex, Inc.”, “price”=>60.17

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ STOCK



8
9
10
11
# File 'lib/stockticker_cli/stock.rb', line 8

def initialize(args) 
    set_attributes(args)
    @@all << self
end

Instance Attribute Details

#changesObject

Returns the value of attribute changes.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def changes
  @changes
end

#changesPercentageObject

Returns the value of attribute changesPercentage.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def changesPercentage
  @changesPercentage
end

#companyNameObject

Returns the value of attribute companyName.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def companyName
  @companyName
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def description
  @description
end

#industryObject

Returns the value of attribute industry.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def industry
  @industry
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def name
  @name
end

#priceObject

Returns the value of attribute price.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def price
  @price
end

#sectorObject

Returns the value of attribute sector.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def sector
  @sector
end

#symbolObject

Returns the value of attribute symbol.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def symbol
  @symbol
end

#tickerObject

Returns the value of attribute ticker.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def ticker
  @ticker
end

#websiteObject

Returns the value of attribute website.



5
6
7
# File 'lib/stockticker_cli/stock.rb', line 5

def website
  @website
end

Class Method Details

.allObject



20
21
22
# File 'lib/stockticker_cli/stock.rb', line 20

def self.all 
    @@all 
end

.resetObject



24
25
26
# File 'lib/stockticker_cli/stock.rb', line 24

def self.reset 
    @@all.clear  
end

Instance Method Details

#set_attributes(hash) ⇒ Object



13
14
15
16
17
18
# File 'lib/stockticker_cli/stock.rb', line 13

def set_attributes(hash) 
    hash.each do |k, v|
        # checks if method exists for instance of stock
        self.send("#{k}=", v) if self.respond_to?(k)
    end 
end