Class: SE::API::Post
- Inherits:
-
Object
- Object
- SE::API::Post
- Defined in:
- lib/se/api/types/post.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
(also: #user, #owner)
readonly
Returns the value of attribute author.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#last_editor ⇒ Object
readonly
Returns the value of attribute last_editor.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#updated_at ⇒ Object
(also: #last_activity_date)
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(item_json) ⇒ Post
constructor
A new instance of Post.
Constructor Details
#initialize(item_json) ⇒ Post
Returns a new instance of Post.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/se/api/types/post.rb', line 9 def initialize(item_json) @json = Hash(item_json) @body = @json["body"] @title = @json["title"] @link = @json["link"] @score = @json["score"].to_i @type = @json["post_type"] @last_editor = User.new(@json["last_editor"]) @comments = Array(@json["comments"]&.map { |c| Comment.new(c) }) @id = (@json["post_id"] || @json["answer_id"] || @json["question_id"]).to_i @updated_at = @json["last_activity_date"] @created_at = @json["creation_date"] @author = User.new(@json["owner"]) end |
Instance Attribute Details
#author ⇒ Object (readonly) Also known as: user, owner
Returns the value of attribute author.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def @author end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def body @body end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def comments @comments end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def id @id end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
7 8 9 |
# File 'lib/se/api/types/post.rb', line 7 def json @json end |
#last_editor ⇒ Object (readonly)
Returns the value of attribute last_editor.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def last_editor @last_editor end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def link @link end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def score @score end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def type @type end |
#updated_at ⇒ Object (readonly) Also known as: last_activity_date
Returns the value of attribute updated_at.
6 7 8 |
# File 'lib/se/api/types/post.rb', line 6 def updated_at @updated_at end |