Class: Yo

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Singleton
Defined in:
lib/yo-ruby.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#api_key=(value) ⇒ Object (writeonly)

Sets the attribute api_key

Parameters:

  • value

    the value to set the attribute api_key to.



14
15
16
# File 'lib/yo-ruby.rb', line 14

def api_key=(value)
  @api_key = value
end

Class Method Details

.allObject



42
43
44
# File 'lib/yo-ruby.rb', line 42

def self.all
	self.__post('/yoall/')["result"] == "OK"
end

.all!Object



46
47
48
# File 'lib/yo-ruby.rb', line 46

def self.all!
	self.all
end

.api_keyObject

Authentication stuffs.



17
18
19
# File 'lib/yo-ruby.rb', line 17

def self.api_key
	@api_key
end

.api_key=(api_key) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/yo-ruby.rb', line 25

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/yo-ruby.rb', line 21

def self.api_key?
	not @api_key.nil?
end

.from(params, username) ⇒ Object



64
65
66
67
# File 'lib/yo-ruby.rb', line 64

def self.from(params, username)
	parameters = __clean(params)
	yield if parameters.keys.length > 0 and parameters.include?(:username)
end

.receive(params) {|parameters[:username].to_s| ... } ⇒ Object

Receive a yo.

Yields:

  • (parameters[:username].to_s)


59
60
61
62
# File 'lib/yo-ruby.rb', line 59

def self.receive(params)
	parameters = __clean(params)
	yield(parameters[:username].to_s) if parameters.keys.length > 0 and parameters.include?(:username)
end

.subscribersObject



50
51
52
# File 'lib/yo-ruby.rb', line 50

def self.subscribers
	self.__get('/subscribers_count/')["result"].to_i
end

.subscribers?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/yo-ruby.rb', line 54

def self.subscribers?
	self.subscribers > 0
end

.yo(username) ⇒ Object

Yo calls.



34
35
36
# File 'lib/yo-ruby.rb', line 34

def self.yo(username)
	self.__post('/yo/', { :username => username })["result"] == "OK"
end

.yo!(username) ⇒ Object



38
39
40
# File 'lib/yo-ruby.rb', line 38

def self.yo!(username)
	self.yo(username)
end