Class: LendingClub::Portfolio
- Inherits:
-
Object
- Object
- LendingClub::Portfolio
- Defined in:
- lib/lending_club/client/portfolio.rb
Constant Summary collapse
- ATTRIBUTES =
[ :portfolio_id, :portfolio_name, :portfolio_description ]
Instance Attribute Summary collapse
-
#portfolio_description ⇒ String?
readonly
Portfolio description.
-
#portfolio_id ⇒ Integer
readonly
Portfolio Id.
-
#portfolio_name ⇒ String
readonly
Portfolio name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data_hash) ⇒ Portfolio
constructor
A new instance of Portfolio.
- #to_h ⇒ Object
Constructor Details
#initialize(data_hash) ⇒ Portfolio
Returns a new instance of Portfolio.
19 20 21 22 23 24 25 |
# File 'lib/lending_club/client/portfolio.rb', line 19 def initialize(data_hash) @portfolio_id = Integer(data_hash['portfolioId']) @portfolio_name = data_hash['portfolioName'].to_s if data_hash['portfolioDescription'] @portfolio_description = data_hash['portfolioDescription'].to_s end end |
Instance Attribute Details
#portfolio_description ⇒ String? (readonly)
Returns Portfolio description.
17 18 19 |
# File 'lib/lending_club/client/portfolio.rb', line 17 def portfolio_description @portfolio_description end |
#portfolio_id ⇒ Integer (readonly)
Returns Portfolio Id.
13 14 15 |
# File 'lib/lending_club/client/portfolio.rb', line 13 def portfolio_id @portfolio_id end |
#portfolio_name ⇒ String (readonly)
Returns Portfolio name.
15 16 17 |
# File 'lib/lending_club/client/portfolio.rb', line 15 def portfolio_name @portfolio_name end |
Class Method Details
.collection(data_hash) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/lending_club/client/portfolio.rb', line 27 def self.collection(data_hash) return [] unless data_hash['myPortfolios'] data_hash['myPortfolios'].map do |portfolio| new(portfolio) end end |
Instance Method Details
#to_h ⇒ Object
34 35 36 37 38 39 |
# File 'lib/lending_club/client/portfolio.rb', line 34 def to_h ATTRIBUTES.reduce({}) do |h, attribute| h[attribute.to_s] = send(attribute) h end end |