Class: Ubiquitously::Queness::Post

Inherits:
Service::Post show all
Defined in:
lib/ubiquitously/services/queness.rb

Instance Attribute Summary

Attributes inherited from Service::Post

#captcha, #categories, #description, #downvotes, #extension, #format, #image, #kind, #must_be_unique, #privacy, #rating, #remote, #service_id, #service_url, #slug, #source, #source_url, #state, #status, #tags, #title, #token, #upvotes, #url, #user, #vote

Instance Method Summary collapse

Methods inherited from Service::Post

#access_token, #initialize

Methods included from Loggable::Post

included

Methods included from Restful::Post

included

Methods included from Postable::Post

included

Methods included from Ownable::Post

included

Methods inherited from Base

#apply, #debug?

Methods included from SubclassableCallbacks

included, override

Constructor Details

This class inherits a constructor from Ubiquitously::Service::Post

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ubiquitously/services/queness.rb', line 17

def create
  page = agent.get("http://www.queness.com/post")
  form = page.forms.detect { |form| !form.form_node.css(".postform").first.nil? }
  
  form["form[title]"] = token[:title]
  form["form[description]"] = token[:description]
  form["form[url]"] = token[:url]
  # 1-4 tags
  form.checkboxes_with(:name => "tags[]").each do |box|
    case box.value.to_s
    when "1", "12", "11", "3"
      box.check
    end
  end
  
  page = form.submit
  
  true
end