class Api2ch::ViewedThreads

Public Class Methods

new(board) click to toggle source
# File lib/api_2ch/methods/viewed_threads.rb, line 3
def initialize(board)
  @board = board
end

Public Instance Methods

call() click to toggle source
# File lib/api_2ch/methods/viewed_threads.rb, line 7
def call
  board_threads = make_request(@board)
  board_threads['threads'].map     { |i| i['subject'].scrub! }
  board_threads['threads'].sort_by { |i| - i['views'] }
end

Private Instance Methods

make_request(board) click to toggle source
# File lib/api_2ch/methods/viewed_threads.rb, line 15
def make_request(board)
  response = HTTParty.get("#{BASE_URL}#{@board}/threads.json")
  JSON.parse(response.body)
end