Class: Api2ch::Posts
- Inherits:
-
Object
- Object
- Api2ch::Posts
- Defined in:
- lib/api_2ch/methods/posts.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(board, num) ⇒ Posts
constructor
A new instance of Posts.
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
#call ⇒ Object
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 |