Class: StockcliApp::Stock
- Inherits:
-
Object
- Object
- StockcliApp::Stock
- Defined in:
- lib/stockcli_app/stock.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#change ⇒ Object
Returns the value of attribute change.
-
#eps ⇒ Object
Returns the value of attribute eps.
-
#index ⇒ Object
Returns the value of attribute index.
-
#mktcap ⇒ Object
Returns the value of attribute mktcap.
-
#name ⇒ Object
Returns the value of attribute name.
-
#peratio ⇒ Object
Returns the value of attribute peratio.
-
#price ⇒ Object
Returns the value of attribute price.
-
#sector ⇒ Object
Returns the value of attribute sector.
-
#srno ⇒ Object
Returns the value of attribute srno.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_stock_info(info) ⇒ Object
-
#initialize(array) ⇒ Stock
constructor
The instances of stocks should be initialized with an array that includes information that was scraped using the scraper class The initialized stock should contain information about the Sr no, name, symbol, url and marketcap.
Constructor Details
#initialize(array) ⇒ Stock
The instances of stocks should be initialized with an array that includes information that was scraped using the scraper class The initialized stock should contain information about the Sr no, name, symbol, url and marketcap
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stockcli_app/stock.rb', line 11 def initialize(array) stock_array = array @srno = stock_array[0] @symbol = stock_array[1] @name = stock_array[2] @url = stock_array[3] @price = stock_array[4] @mktcap = stock_array[5] @sector = stock_array[6] @change = stock_array[7] @@all << self end |
Instance Attribute Details
#change ⇒ Object
Returns the value of attribute change.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def change @change end |
#eps ⇒ Object
Returns the value of attribute eps.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def eps @eps end |
#index ⇒ Object
Returns the value of attribute index.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def index @index end |
#mktcap ⇒ Object
Returns the value of attribute mktcap.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def mktcap @mktcap end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def name @name end |
#peratio ⇒ Object
Returns the value of attribute peratio.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def peratio @peratio end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def price @price end |
#sector ⇒ Object
Returns the value of attribute sector.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def sector @sector end |
#srno ⇒ Object
Returns the value of attribute srno.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def srno @srno end |
#symbol ⇒ Object
Returns the value of attribute symbol.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def symbol @symbol end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/stockcli_app/stock.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
31 32 33 |
# File 'lib/stockcli_app/stock.rb', line 31 def self.all @@all end |
.create_from_scraper_array(outer_array) ⇒ Object
24 25 26 27 28 |
# File 'lib/stockcli_app/stock.rb', line 24 def self.create_from_scraper_array(outer_array) outer_array.each do |inner_array| stock = StockcliApp::Stock.new(inner_array) end end |
Instance Method Details
#add_stock_info(info) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/stockcli_app/stock.rb', line 35 def add_stock_info(info) array = info @index = array[0] @peratio = array[1] @eps = array[2] end |