Class: Kiva::Comment
- Inherits:
-
Object
- Object
- Kiva::Comment
- Defined in:
- lib/kiva.rb
Overview
User comment made in response to a JournalEntry.
Constant Summary collapse
- KEY =
"comments"
- URL =
"http://api.kivaws.org/v1/journal_entries/%s/comments.json?"
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#body ⇒ Object
api.kivaws.org/v1/journal_entries/<id>/comments.json.
-
#date ⇒ Object
Returns the value of attribute date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
Class Method Summary collapse
-
.load(id, page = nil) ⇒ Object
Loads an array of comments for a JournalEntry.
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
482 483 484 |
# File 'lib/kiva.rb', line 482 def @author end |
#body ⇒ Object
api.kivaws.org/v1/journal_entries/<id>/comments.json
480 481 482 |
# File 'lib/kiva.rb', line 480 def body @body end |
#date ⇒ Object
Returns the value of attribute date.
481 482 483 |
# File 'lib/kiva.rb', line 481 def date @date end |
#id ⇒ Object
Returns the value of attribute id.
483 484 485 |
# File 'lib/kiva.rb', line 483 def id @id end |
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
484 485 486 |
# File 'lib/kiva.rb', line 484 def whereabouts @whereabouts end |
Class Method Details
.load(id, page = nil) ⇒ Object
Loads an array of comments for a JournalEntry.
Parameters
-
id
: the numerical id of a Journal Entry or an instance of the classJournalEntry
-
page
: which page of comments to load, default is the first.
Returns
array of Comments
Corresponds
developers.wiki.kiva.org/KivaAPI#journalentries/ltidgt/comments
503 504 505 506 507 508 509 510 511 512 |
# File 'lib/kiva.rb', line 503 def load id, page=nil id = id.id if id.is_a?(JournalEntry) url = URL % id url = page ? url + "page=#{page}&" : url raw = raw = Kiva.execute(url) unw = JSON.parse(raw) Kiva._populate Comment, unw[KEY] end |