Class: Result
- Inherits:
-
Object
- Object
- Result
- Defined in:
- lib/alphavcli/result.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#daily ⇒ Object
Returns the value of attribute daily.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ticker ⇒ Object
Returns the value of attribute ticker.
Class Method Summary collapse
Instance Method Summary collapse
- #getTimeSeries ⇒ Object
-
#initialize(ticker, name = nil) ⇒ Result
constructor
A new instance of Result.
- #week ⇒ Object
Constructor Details
#initialize(ticker, name = nil) ⇒ Result
4 5 6 7 8 |
# File 'lib/alphavcli/result.rb', line 4 def initialize(ticker,name=nil) @ticker=ticker @name=name @@all.push(self) end |
Instance Attribute Details
#daily ⇒ Object
Returns the value of attribute daily.
2 3 4 |
# File 'lib/alphavcli/result.rb', line 2 def daily @daily end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/alphavcli/result.rb', line 2 def name @name end |
#ticker ⇒ Object
Returns the value of attribute ticker.
2 3 4 |
# File 'lib/alphavcli/result.rb', line 2 def ticker @ticker end |
Class Method Details
.all ⇒ Object
29 30 31 |
# File 'lib/alphavcli/result.rb', line 29 def self.all @@all end |
.new_from_ticker(ticker) ⇒ Object
10 11 12 13 |
# File 'lib/alphavcli/result.rb', line 10 def self.new_from_ticker(ticker) new_result = self.new(ticker) self.new(ticker) end |
Instance Method Details
#getTimeSeries ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/alphavcli/result.rb', line 15 def getTimeSeries data = open("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=#{@ticker}&apikey=#{Alphavcli::Cli.returnKey}").read data = JSON.parse(data) #data = data["Time Series (Daily)"] @daily = data = data["Time Series (Daily)"].map{|k,v| {:day=>k, :price=>v["4. close"].to_f} } end |
#week ⇒ Object
25 26 27 |
# File 'lib/alphavcli/result.rb', line 25 def week getTimeSeries end |