Class: Kiva::Lender
- Inherits:
-
Object
- Object
- Kiva::Lender
- Defined in:
- lib/kiva.rb
Overview
Represents a Lender (whoda guessed.) The accessible parameters are all all there is to this. Depending on how a particular instance of loan was loaded, not all of the attributes need have a value, so remember to check for nil
.
Use one of the class functions:
-
load
-
load_for_loan
to load lender information from Kiva.
Constant Summary collapse
- KEY =
"lenders"
- LOAD =
"http://api.kivaws.org/v1/lenders/%s.json"
- LOAD_FOR_LOAN =
"http://api.kivaws.org/v1/loans/%s/lenders.json?"
Instance Attribute Summary collapse
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#image ⇒ Object
Returns the value of attribute image.
-
#invitee_count ⇒ Object
Returns the value of attribute invitee_count.
-
#lender_id ⇒ Object
Returns the value of attribute lender_id.
-
#loan_because ⇒ Object
Returns the value of attribute loan_because.
-
#loan_count ⇒ Object
Returns the value of attribute loan_count.
-
#member_since ⇒ Object
Returns the value of attribute member_since.
-
#name ⇒ Object
Returns the value of attribute name.
-
#occupation ⇒ Object
Returns the value of attribute occupation.
-
#occupational_info ⇒ Object
Returns the value of attribute occupational_info.
-
#personal_url ⇒ Object
Returns the value of attribute personal_url.
-
#uid ⇒ Object
url = “api.kivaws.org/v1/lenders/%s.json”.
-
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
Class Method Summary collapse
-
.load(ids) ⇒ Object
Load details for one or more Lenders.
-
.load_for_loan(loan, page = nil) ⇒ Object
List public lenders of a loan.
Instance Attribute Details
#country_code ⇒ Object
Returns the value of attribute country_code.
279 280 281 |
# File 'lib/kiva.rb', line 279 def country_code @country_code end |
#image ⇒ Object
Returns the value of attribute image.
285 286 287 |
# File 'lib/kiva.rb', line 285 def image @image end |
#invitee_count ⇒ Object
Returns the value of attribute invitee_count.
281 282 283 |
# File 'lib/kiva.rb', line 281 def invitee_count @invitee_count end |
#lender_id ⇒ Object
Returns the value of attribute lender_id.
275 276 277 |
# File 'lib/kiva.rb', line 275 def lender_id @lender_id end |
#loan_because ⇒ Object
Returns the value of attribute loan_because.
280 281 282 |
# File 'lib/kiva.rb', line 280 def loan_because @loan_because end |
#loan_count ⇒ Object
Returns the value of attribute loan_count.
277 278 279 |
# File 'lib/kiva.rb', line 277 def loan_count @loan_count end |
#member_since ⇒ Object
Returns the value of attribute member_since.
286 287 288 |
# File 'lib/kiva.rb', line 286 def member_since @member_since end |
#name ⇒ Object
Returns the value of attribute name.
276 277 278 |
# File 'lib/kiva.rb', line 276 def name @name end |
#occupation ⇒ Object
Returns the value of attribute occupation.
278 279 280 |
# File 'lib/kiva.rb', line 278 def occupation @occupation end |
#occupational_info ⇒ Object
Returns the value of attribute occupational_info.
282 283 284 |
# File 'lib/kiva.rb', line 282 def occupational_info @occupational_info end |
#personal_url ⇒ Object
Returns the value of attribute personal_url.
283 284 285 |
# File 'lib/kiva.rb', line 283 def personal_url @personal_url end |
#uid ⇒ Object
274 275 276 |
# File 'lib/kiva.rb', line 274 def uid @uid end |
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
284 285 286 |
# File 'lib/kiva.rb', line 284 def whereabouts @whereabouts end |
Class Method Details
.load(ids) ⇒ Object
Load details for one or more Lenders.
Parameters
ids
: a lender id or and array of id’s
Returns
an array of Lender
instances.
Corresponds
335 336 337 338 339 340 341 342 |
# File 'lib/kiva.rb', line 335 def load ids ids = ids.join(",") if ids.is_a?(Array) url = LOAD % ids raw = Kiva.execute(url) unw = JSON.parse(raw) Kiva._populate Lender, unw[KEY] end |
.load_for_loan(loan, page = nil) ⇒ Object
List public lenders of a loan.
Parameters
loan
: a loan id or an instance of Loan
Returns
an array of Lender
instances.
Corresponds
309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/kiva.rb', line 309 def load_for_loan loan, page = nil loan = loan.id if loan.is_a?(Loan) url = LOAD_FOR_LOAN % loan url = page ? url + "page=#{page}&" : url raw = Kiva.execute(url) unw = JSON.parse(raw) Kiva._populate Lender, unw[KEY] end |