class SE::API::Post

Attributes

author[R]
body[R]
comments[R]
created_at[R]
id[R]
json[R]
last_activity_date[R]
last_editor[R]
owner[R]
score[R]
title[R]
type[R]
updated_at[R]
user[R]

Public Class Methods

new(item_json) click to toggle source
# 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