Class: MarkIt::Quote
Overview
To use, initialize with MarkIt::Quote.new(ticker) where ticker is a string of the company’s trading symbol e.g. aapl = MarkIt::Quote.new(“AAPL”)
Instance Attribute Summary collapse
-
#info ⇒ Object
Returns the value of attribute info.
-
#ticker ⇒ Object
Returns the value of attribute ticker.
Instance Method Summary collapse
- #change_ytd ⇒ Object
-
#initialize(ticker) ⇒ Quote
constructor
ticker is a string of the company’s trading symbol.
Constructor Details
#initialize(ticker) ⇒ Quote
ticker is a string of the company’s trading symbol
30 31 32 33 34 35 36 |
# File 'lib/markit.rb', line 30 def initialize(ticker) #ticker is a string of the company's trading symbol self.ticker = ticker self.info = self.class.get("symbol=#{ticker}") #GET method if self.info["Error"] self.info = "Error. Please enter a new ticker." end end |
Instance Attribute Details
#info ⇒ Object
Returns the value of attribute info.
26 27 28 |
# File 'lib/markit.rb', line 26 def info @info end |
#ticker ⇒ Object
Returns the value of attribute ticker.
26 27 28 |
# File 'lib/markit.rb', line 26 def ticker @ticker end |
Instance Method Details
#change_ytd ⇒ Object
46 47 48 |
# File 'lib/markit.rb', line 46 def change_ytd (last_price.to_f - info["QuoteApiModel"]["Data"]["ChangeYTD"].to_f).to_s end |