Class: Love
- Inherits:
-
Object
show all
- Defined in:
- lib/love.rb
Defined Under Namespace
Classes: Exception, Unauthorized
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(account, api_key, options = {}) ⇒ Love
Returns a new instance of Love.
21
22
23
24
25
26
|
# File 'lib/love.rb', line 21
def initialize(account, api_key, options = {})
@account, @api_key = account, api_key
@sleep_between_requests = options[:sleep_between_requests] || 0.5
end
|
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
16
17
18
|
# File 'lib/love.rb', line 16
def account
@account
end
|
#api_key ⇒ Object
Returns the value of attribute api_key.
17
18
19
|
# File 'lib/love.rb', line 17
def api_key
@api_key
end
|
#logger ⇒ Object
Returns the value of attribute logger.
14
15
16
|
# File 'lib/love.rb', line 14
def logger
@logger
end
|
#sleep_between_requests ⇒ Object
Returns the value of attribute sleep_between_requests.
19
20
21
|
# File 'lib/love.rb', line 19
def sleep_between_requests
@sleep_between_requests
end
|
Class Method Details
.connect(account, api_key, options = {}) ⇒ Object
28
29
30
|
# File 'lib/love.rb', line 28
def self.connect(account, api_key, options = {})
new(account, api_key, options)
end
|
Instance Method Details
#each_category(options = {}, &block) ⇒ Object
50
51
52
|
# File 'lib/love.rb', line 50
def each_category(options = {}, &block)
buffered_each('categories', 'categories', options, &block)
end
|
#each_discussion(options = {}, &block) ⇒ Object
62
63
64
|
# File 'lib/love.rb', line 62
def each_discussion(options = {}, &block)
buffered_each('discussions', 'discussions', options, &block)
end
|
#each_queue(options = {}, &block) ⇒ Object
54
55
56
|
# File 'lib/love.rb', line 54
def each_queue(options = {}, &block)
buffered_each('queues', 'named_queues', options, &block)
end
|
#each_user(options = {}, &block) ⇒ Object
58
59
60
|
# File 'lib/love.rb', line 58
def each_user(options = {}, &block)
buffered_each('users', 'users', options, &block)
end
|
#get_discussion(id_or_href, options = {}) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/love.rb', line 41
def get_discussion(id_or_href, options = {})
if id_or_href.to_s =~ /(\d+)$/
get("discussions/#{$1}", options)
else
nil
end
end
|
#get_user(id_or_href, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/love.rb', line 32
def get_user(id_or_href, options = {})
if id_or_href.to_s =~ /(\d+)$/
get("users/#{$1}", options)
else
nil
end
end
|