Module: Greentext::Client::Post

Included in:
Greentext::Client
Defined in:
lib/greentext/client/post.rb

Overview

Internal: Methods for interacting with posts

Instance Method Summary collapse

Instance Method Details

#expand(post) ⇒ Object

Public: Get the expanded threads given a Greentext::Post object.

This will only work if the post is OP.

post - a Greentext::Post object.

Returns an Array of Greentext::Post instances.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/greentext/client/post.rb', line 13

def expand(post)
  if post.op?
    posts = get("/#{post.board.name}/res/#{post.no}.json")["posts"]
    posts.map do |params|
      params.merge!("board" => post.board)
      Greentext::Post.new(params)
    end
  else
    fail ArgumentError, "This is not the first post in the thread."
  end
end