Class: Api2ch::LatestThreads
- Inherits:
-
Object
- Object
- Api2ch::LatestThreads
- Defined in:
- lib/api_2ch/methods/latest_threads.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(board) ⇒ LatestThreads
constructor
A new instance of LatestThreads.
Constructor Details
#initialize(board) ⇒ LatestThreads
Returns a new instance of LatestThreads.
3 4 5 |
# File 'lib/api_2ch/methods/latest_threads.rb', line 3 def initialize(board) @board = board end |
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/api_2ch/methods/latest_threads.rb', line 7 def call response = HTTParty.get("#{BASE_URL}#{@board}/catalog.json") json = JSON.parse(response.body) @subjects = [] @comments = [] json['threads'].each do |thread| @subjects << thread['subject'] @comments << thread['comment'] end Hash[@subjects.zip(@comments)] end |