Module: Greentext::Client::Board
- Included in:
- Greentext::Client
- Defined in:
- lib/greentext/client/board.rb
Overview
Internal: Methods for interacting with boards.
Instance Method Summary collapse
-
#boards ⇒ Object
Public: List all the boards available.
-
#threads(board) ⇒ Object
Public: List all available threads in a board.
Instance Method Details
#boards ⇒ Object
Public: List all the boards available.
Returns an Array of Greentext::Board instances.
10 11 12 13 |
# File 'lib/greentext/client/board.rb', line 10 def boards boards = get("/boards.json")["boards"] boards.map { |board| Greentext::Board.new(board) } end |
#threads(board) ⇒ Object
Public: List all available threads in a board.
board - A Greentext::Board object or a board name String/Symbol.
Returns an Array of Greentext::Post instances.
20 21 22 23 24 25 |
# File 'lib/greentext/client/board.rb', line 20 def threads(board) name = board.is_a?(Greentext::Board) ? board.name : board get("/#{name}/catalog.json") .map { |page| page["threads"] }.flatten .map { |thread| Greentext::Post.new(thread.merge("board" => board)) } end |