Class: Snoo::Client
Overview
Snoo reddit API wrapper
Instance Attribute Summary collapse
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
-
#modhash ⇒ Object
readonly
Returns the value of attribute modhash.
-
#userid ⇒ Object
readonly
Returns the value of attribute userid.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
Creates a new instance of Snoo.
Constructor Details
#initialize(opts = {}) ⇒ Client
Creates a new instance of Snoo.
As of 0.1.0.pre.4, you can auth or log-in via initializers, saving you from having to run the log-in or auth command seperately. Simply pass username-password options, OR modhash-cookie options (you cannot do both)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/snoo.rb', line 35 def initialize( opts = {} ) = {url: "http://www.reddit.com", useragent: "Snoo ruby reddit api wrapper v#{VERSION}" }.merge opts @baseurl = [:url] self.class.base_uri [:url] @headers = {'User-Agent' => [:useragent] } self.class.headers @headers @cookies = nil @modhash = nil if !([:username].nil? && [:password].nil?) self.log_in [:username], [:password] elsif !([:modhash].nil? && [:cookies].nil?) self.auth [:modhash], [:cookies] end end |
Instance Attribute Details
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
20 21 22 |
# File 'lib/snoo.rb', line 20 def @cookies end |
#modhash ⇒ Object (readonly)
Returns the value of attribute modhash.
20 21 22 |
# File 'lib/snoo.rb', line 20 def modhash @modhash end |
#userid ⇒ Object (readonly)
Returns the value of attribute userid.
20 21 22 |
# File 'lib/snoo.rb', line 20 def userid @userid end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
20 21 22 |
# File 'lib/snoo.rb', line 20 def username @username end |