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.



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_keyObject

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

Returns:

  • (Boolean)


27
28
29
# File 'lib/yo-ruby.rb', line 27

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

.from(params, username) ⇒ Object



70
71
72
73
# File 'lib/yo-ruby.rb', line 70

def self.from(params, username)
	parameters = __clean(params)
	yield if block_given? and parameters.include?(:username) and parameters[:username].to_s.upcase == username.upcase
end

Yields:

  • (parameters[:link].to_s)


81
82
83
84
# File 'lib/yo-ruby.rb', line 81

def self.from_with_link(params, username)
	parameters = __clean(params)
	yield(parameters[:link].to_s) if block_given? and parameters.include?(:username) and parameters.include?(:link) and parameters[:username].to_s.upcase == username.upcase
end

.from_with_location(params, username) {|parameters[:link].to_s, lat, lon| ... } ⇒ Object

Yields:

  • (parameters[:link].to_s, lat, lon)


93
94
95
96
97
# File 'lib/yo-ruby.rb', line 93

def self.from_with_location(params, username)
	parameters = __clean(params)
	lat, lon = parameters[:location].to_s.split(';').map{ |i| i.to_f }
	yield(parameters[:link].to_s, lat, lon) if block_given? and parameters.include?(:username) and parameters.include?(:location) and parameters[:username].to_s.upcase == username.upcase
end

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

Receive a basic yo.

Yields:

  • (parameters[:username].to_s)


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

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

Receive a yo with a link (also known as YOLINK).

Yields:

  • (parameters[:username].to_s, parameters[:link].to_s)


76
77
78
79
# File 'lib/yo-ruby.rb', line 76

def self.receive_with_link(params)
	parameters = __clean(params)
	yield(parameters[:username].to_s, parameters[:link].to_s) if block_given? and parameters.include?(:username) and parameters.include?(:link)
end

.receive_with_location(params) {|parameters[:username].to_s, lat, lon| ... } ⇒ Object

Receive a yo with a location (also known as @YO).

Yields:

  • (parameters[:username].to_s, lat, lon)


87
88
89
90
91
# File 'lib/yo-ruby.rb', line 87

def self.receive_with_location(params)
	parameters = __clean(params)
	lat, lon = parameters[:location].to_s.split(';').map{ |i| i.to_f }
	yield(parameters[:username].to_s, lat, lon) if block_given? and parameters.include?(:username) and parameters.include?(:location)
end

.subscribersObject



56
57
58
# File 'lib/yo-ruby.rb', line 56

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

.subscribers?Boolean

Returns:

  • (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