Class: KivaApi::CommentsResponse
- Inherits:
-
Object
- Object
- KivaApi::CommentsResponse
- Defined in:
- lib/kiva_api/comments_response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #comment_count ⇒ Object
- #comments ⇒ Object
-
#initialize(parsed_response) ⇒ CommentsResponse
constructor
A new instance of CommentsResponse.
Constructor Details
#initialize(parsed_response) ⇒ CommentsResponse
Returns a new instance of CommentsResponse.
4 5 6 |
# File 'lib/kiva_api/comments_response.rb', line 4 def initialize(parsed_response) @response = parsed_response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
2 3 4 |
# File 'lib/kiva_api/comments_response.rb', line 2 def response @response end |
Instance Method Details
#comment_count ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/kiva_api/comments_response.rb', line 24 def comment_count if @response.present? and @response["properties"].is_a?(Hash) @response["properties"]["count"] else 0 end end |
#comments ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kiva_api/comments_response.rb', line 8 def comments if @response.present? and @response["entities"] comments = [] @response["entities"].each do |comment| comments << { body: comment["properties"]["body"], date: comment["properties"]["date"], author: comment["properties"]["authorName"] } end comments else [] end end |