Class: Ubiquitously::Reddit::Post

Inherits:
Base::Post show all
Defined in:
lib/ubiquitously/reddit.rb

Instance Attribute Summary

Attributes inherited from Base::Post

#categories, #description, #service_url, #tags, #title, #url, #user

Instance Method Summary collapse

Methods inherited from Base::Post

#agent, create

Methods included from Ubiquitously::Resourceful

included

Instance Method Details

#save(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ubiquitously/reddit.rb', line 26

def save(options = {})
  return false unless valid?
  
  user.
  
  page = agent.get("http://www.reddit.com/submit")
  form = page.forms.detect {|form| form.form_node["id"] == "newlink"}
  form["title"] = title
  form["url"]   = url
  form["id"] = "#newlink"
  form.action = "http://www.reddit.com/api/submit"
  headers = {
    "Content-Type" => "application/json"
  }
  unless options[:debug] == true
    page = form.submit(nil, headers)
  end
end