Class: Ubiquitously::Reddit::Post
- Inherits:
-
Base::Post
- Object
- Base::Post
- Ubiquitously::Reddit::Post
- 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
Methods included from Ubiquitously::Resourceful
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( = {}) return false unless valid? user.login 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 [:debug] == true page = form.submit(nil, headers) end end |