Class: GMoney::Portfolio
- Inherits:
-
Object
- Object
- GMoney::Portfolio
- Defined in:
- lib/gmoney/portfolio.rb
Defined Under Namespace
Classes: PortfolioRequestError
Instance Attribute Summary collapse
-
#cost_basis ⇒ Object
readonly
Returns the value of attribute cost_basis.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#days_gain ⇒ Object
readonly
Returns the value of attribute days_gain.
-
#feed_link ⇒ Object
readonly
Returns the value of attribute feed_link.
-
#gain ⇒ Object
readonly
Returns the value of attribute gain.
-
#gain_percentage ⇒ Object
readonly
Returns the value of attribute gain_percentage.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#market_value ⇒ Object
readonly
Returns the value of attribute market_value.
-
#positions ⇒ Object
Returns the value of attribute positions.
-
#return1w ⇒ Object
readonly
Returns the value of attribute return1w.
-
#return1y ⇒ Object
readonly
Returns the value of attribute return1y.
-
#return3m ⇒ Object
readonly
Returns the value of attribute return3m.
-
#return3y ⇒ Object
readonly
Returns the value of attribute return3y.
-
#return4w ⇒ Object
readonly
Returns the value of attribute return4w.
-
#return5y ⇒ Object
readonly
Returns the value of attribute return5y.
-
#return_overall ⇒ Object
readonly
Returns the value of attribute return_overall.
-
#return_ytd ⇒ Object
readonly
Returns the value of attribute return_ytd.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Portfolio
constructor
A new instance of Portfolio.
Constructor Details
#initialize ⇒ Portfolio
Returns a new instance of Portfolio.
11 12 13 |
# File 'lib/gmoney/portfolio.rb', line 11 def initialize() @positions = [] end |
Instance Attribute Details
#cost_basis ⇒ Object (readonly)
Returns the value of attribute cost_basis.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def cost_basis @cost_basis end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
5 6 7 |
# File 'lib/gmoney/portfolio.rb', line 5 def currency_code @currency_code end |
#days_gain ⇒ Object (readonly)
Returns the value of attribute days_gain.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def days_gain @days_gain end |
#feed_link ⇒ Object (readonly)
Returns the value of attribute feed_link.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def feed_link @feed_link end |
#gain ⇒ Object (readonly)
Returns the value of attribute gain.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def gain @gain end |
#gain_percentage ⇒ Object (readonly)
Returns the value of attribute gain_percentage.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def gain_percentage @gain_percentage end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def id @id end |
#market_value ⇒ Object (readonly)
Returns the value of attribute market_value.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def market_value @market_value end |
#positions ⇒ Object
Returns the value of attribute positions.
5 6 7 |
# File 'lib/gmoney/portfolio.rb', line 5 def positions @positions end |
#return1w ⇒ Object (readonly)
Returns the value of attribute return1w.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return1w @return1w end |
#return1y ⇒ Object (readonly)
Returns the value of attribute return1y.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return1y @return1y end |
#return3m ⇒ Object (readonly)
Returns the value of attribute return3m.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return3m @return3m end |
#return3y ⇒ Object (readonly)
Returns the value of attribute return3y.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return3y @return3y end |
#return4w ⇒ Object (readonly)
Returns the value of attribute return4w.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return4w @return4w end |
#return5y ⇒ Object (readonly)
Returns the value of attribute return5y.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return5y @return5y end |
#return_overall ⇒ Object (readonly)
Returns the value of attribute return_overall.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return_overall @return_overall end |
#return_ytd ⇒ Object (readonly)
Returns the value of attribute return_ytd.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def return_ytd @return_ytd end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/gmoney/portfolio.rb', line 5 def title @title end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
7 8 9 |
# File 'lib/gmoney/portfolio.rb', line 7 def updated @updated end |
Class Method Details
.all(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gmoney/portfolio.rb', line 15 def self.all( = {}) url = "#{GF_FEED_URL}/portfolios" url += "?returns=true" if [:with_returns] portfolios = [] response = GFService.send_request(GFRequest.new(url, :headers => {"Authorization" => "GoogleLogin auth=#{GFSession.auth_token}"})) if response.status_code == HTTPOK portfolios = PortfolioFeedParser.parse_portfolio_feed(response.body) else raise PortfolioRequestError end portfolios.each do |portfolio| portfolio.positions = Position.find_by_url(portfolio.feed_link, {:with_returns => [:with_returns]}) end portfolios end |