Module: ProductHunt::API::Posts

Included in:
ProductHunt::API
Defined in:
lib/product_hunt/api/posts.rb

Constant Summary collapse

PATH =
"/posts"

Instance Method Summary collapse

Instance Method Details

#all_posts(options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/product_hunt/api/posts.rb', line 13

def all_posts(options = {})
  process(PATH + "/all", options) do |response|
    response["posts"].map{ |post| Post.new(post, self) }
  end
end

#comments_for_post(id, options = {}) ⇒ Object



25
26
27
28
29
# File 'lib/product_hunt/api/posts.rb', line 25

def comments_for_post(id, options = {})
  process(PATH + "/#{id}/comments", options) do |response|
    response["comments"].map{ |c| Comment.new(c, self) }
  end
end

#post(id, options = {}) ⇒ Object



19
20
21
22
23
# File 'lib/product_hunt/api/posts.rb', line 19

def post(id, options = {})
  process(PATH + "/#{id}", options) do |response|
    Post.new(response["post"], self)
  end
end

#posts(options = {}) ⇒ Object



7
8
9
10
11
# File 'lib/product_hunt/api/posts.rb', line 7

def posts(options = {})
  process(PATH, options) do |response|
    response["posts"].map{ |post| Post.new(post, self) }
  end
end

#votes_for_post(id, options = {}) ⇒ Object



31
32
33
34
35
# File 'lib/product_hunt/api/posts.rb', line 31

def votes_for_post(id, options = {})
  process(PATH + "/#{id}/votes", options) do |response|
    response["votes"].map{ |c| Vote.new(c, self) }
  end
end