Class: Yo
Instance Attribute Summary collapse
-
#api_key ⇒ Object
writeonly
Sets the attribute api_key.
Class Method Summary collapse
- .all(extra_params = {}) ⇒ Object
- .all!(extra_params = {}) ⇒ Object
-
.api_key ⇒ Object
Authentication stuffs.
- .api_key=(api_key) ⇒ Object
- .api_key? ⇒ Boolean
- .from(params, username) {|link| ... } ⇒ Object
-
.receive(params) {|parameters[:username].to_s, link| ... } ⇒ Object
Receive a yo.
- .subscribers ⇒ Object
- .subscribers? ⇒ Boolean
-
.yo(username, extra_params = {}) ⇒ Object
Yo calls.
- .yo!(username, extra_params = {}) ⇒ Object
Instance Attribute Details
#api_key=(value) ⇒ Object (writeonly)
Sets the attribute api_key
20 21 22 |
# File 'lib/yo-ruby.rb', line 20 def api_key=(value) @api_key = value end |
Class Method Details
.all(extra_params = {}) ⇒ Object
48 49 50 |
# File 'lib/yo-ruby.rb', line 48 def self.all(extra_params = {}) self.__post('/yoall/', extra_params)["result"] == "OK" end |
.all!(extra_params = {}) ⇒ Object
52 53 54 |
# File 'lib/yo-ruby.rb', line 52 def self.all!(extra_params = {}) self.all(extra_params) end |
.api_key ⇒ Object
Authentication stuffs.
23 24 25 |
# File 'lib/yo-ruby.rb', line 23 def self.api_key @api_key end |
.api_key=(api_key) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/yo-ruby.rb', line 31 def self.api_key=(api_key) if api_key.to_s.length != 36 or not api_key.is_a?(String) raise YoException.new("Invalid Yo API key - must be 36 characters in length") end @api_key = api_key end |
.api_key? ⇒ Boolean
27 28 29 |
# File 'lib/yo-ruby.rb', line 27 def self.api_key? not @api_key.nil? end |
.from(params, username) {|link| ... } ⇒ Object
71 72 73 74 75 |
# File 'lib/yo-ruby.rb', line 71 def self.from(params, username) parameters = __clean(params) link = parameters.keys.include?(:link) ? parameters[:link] : nil yield(link) if parameters.keys.length > 0 and parameters.include?(:username) and params[:username].to_s.upcase == username.upcase end |
.receive(params) {|parameters[:username].to_s, link| ... } ⇒ Object
Receive a yo.
65 66 67 68 69 |
# File 'lib/yo-ruby.rb', line 65 def self.receive(params) parameters = __clean(params) link = parameters.keys.include?(:link) ? parameters[:link] : nil yield(parameters[:username].to_s, link) if parameters.keys.length > 0 and parameters.include?(:username) end |
.subscribers ⇒ Object
56 57 58 |
# File 'lib/yo-ruby.rb', line 56 def self.subscribers self.__get('/subscribers_count/')["result"].to_i end |
.subscribers? ⇒ Boolean
60 61 62 |
# File 'lib/yo-ruby.rb', line 60 def self.subscribers? self.subscribers > 0 end |
.yo(username, extra_params = {}) ⇒ Object
Yo calls.
40 41 42 |
# File 'lib/yo-ruby.rb', line 40 def self.yo(username, extra_params = {}) self.__post('/yo/', { :username => username }.merge(extra_params))["result"] == "OK" end |
.yo!(username, extra_params = {}) ⇒ Object
44 45 46 |
# File 'lib/yo-ruby.rb', line 44 def self.yo!(username, extra_params = {}) self.yo(username, extra_params) end |