Class: Api2ch::Posts

Inherits:
Object
  • Object
show all
Defined in:
lib/api_2ch/methods/posts.rb

Instance Method Summary collapse

Constructor Details

#initialize(board, num) ⇒ Posts

Returns a new instance of Posts.



3
4
5
6
# File 'lib/api_2ch/methods/posts.rb', line 3

def initialize(board, num)
  @board = board
  @num   = num
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
# File 'lib/api_2ch/methods/posts.rb', line 8

def call
  response = HTTParty.get("#{BASE_URL}#{@board}/res/#{@num}.json")
  json     = JSON.parse(response.body)
  json['threads'].each do |thread|
    return thread['posts'].map { |post| post }
  end
end