Class: Forrst::Comment
- Inherits:
-
Object
- Object
- Forrst::Comment
- Defined in:
- lib/forrst/comment.rb
Overview
Forrst::Comment is a class used for individual comments.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
The body of the comment.
-
#comment_id ⇒ Object
readonly
The ID of the comment.
-
#created_at ⇒ Object
readonly
The date and time on which the comment was created.
-
#updated_at ⇒ Object
readonly
The date and time on which the comment was updated.
-
#user ⇒ Object
readonly
An instance of Forrst::User containing the details of the user.
Instance Method Summary collapse
-
#initialize(response) ⇒ Comment
constructor
Creates a new instance of Forrst::Comment and parses the response (either in JSON or as a has).
Constructor Details
#initialize(response) ⇒ Comment
Creates a new instance of Forrst::Comment and parses the response (either in JSON or as a has).
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/forrst/comment.rb', line 57 def initialize(response) if response.class != Hash response = JSON.load(response) end @comment_id = response['id'] @user = Forrst::User.new(response['user']) @body = response['body'] @created_at = Date.strptime(response['created_at'], Forrst::DateFormat) @updated_at = Date.strptime(response['updated_at'], Forrst::DateFormat) end |
Instance Attribute Details
#body ⇒ Object (readonly)
The body of the comment.
31 32 33 |
# File 'lib/forrst/comment.rb', line 31 def body @body end |
#comment_id ⇒ Object (readonly)
The ID of the comment.
15 16 17 |
# File 'lib/forrst/comment.rb', line 15 def comment_id @comment_id end |
#created_at ⇒ Object (readonly)
The date and time on which the comment was created.
39 40 41 |
# File 'lib/forrst/comment.rb', line 39 def created_at @created_at end |
#updated_at ⇒ Object (readonly)
The date and time on which the comment was updated.
47 48 49 |
# File 'lib/forrst/comment.rb', line 47 def updated_at @updated_at end |
#user ⇒ Object (readonly)
An instance of Forrst::User containing the details of the user.
23 24 25 |
# File 'lib/forrst/comment.rb', line 23 def user @user end |