Class: StocktickerCli::STOCK
- Inherits:
-
Object
- Object
- StocktickerCli::STOCK
- Defined in:
- lib/stockticker_cli/stock.rb
Overview
“symbol”=>“PAYX”, “name”=>“Paychex, Inc.”, “price”=>60.17
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#changesPercentage ⇒ Object
Returns the value of attribute changesPercentage.
-
#companyName ⇒ Object
Returns the value of attribute companyName.
-
#description ⇒ Object
Returns the value of attribute description.
-
#industry ⇒ Object
Returns the value of attribute industry.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#sector ⇒ Object
Returns the value of attribute sector.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#ticker ⇒ Object
Returns the value of attribute ticker.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ STOCK
constructor
A new instance of STOCK.
- #set_attributes(hash) ⇒ Object
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
#changes ⇒ Object
Returns the value of attribute changes.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def changes @changes end |
#changesPercentage ⇒ Object
Returns the value of attribute changesPercentage.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def changesPercentage @changesPercentage end |
#companyName ⇒ Object
Returns the value of attribute companyName.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def companyName @companyName end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def description @description end |
#industry ⇒ Object
Returns the value of attribute industry.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def industry @industry end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def price @price end |
#sector ⇒ Object
Returns the value of attribute sector.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def sector @sector end |
#symbol ⇒ Object
Returns the value of attribute symbol.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def symbol @symbol end |
#ticker ⇒ Object
Returns the value of attribute ticker.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def ticker @ticker end |
#website ⇒ Object
Returns the value of attribute website.
5 6 7 |
# File 'lib/stockticker_cli/stock.rb', line 5 def website @website end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/stockticker_cli/stock.rb', line 20 def self.all @@all end |
.reset ⇒ Object
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 |