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.
448 449 450 |
# File 'lib/kiva.rb', line 448 def @author end |
#body ⇒ Object
api.kivaws.org/v1/journal_entries/<id>/comments.json
446 447 448 |
# File 'lib/kiva.rb', line 446 def body @body end |
#date ⇒ Object
Returns the value of attribute date.
447 448 449 |
# File 'lib/kiva.rb', line 447 def date @date end |
#id ⇒ Object
Returns the value of attribute id.
449 450 451 |
# File 'lib/kiva.rb', line 449 def id @id end |
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
450 451 452 |
# File 'lib/kiva.rb', line 450 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
469 470 471 472 473 474 475 476 477 478 |
# File 'lib/kiva.rb', line 469 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 |