Class: TwilioRubyWrapper::Queue
- Inherits:
-
Object
- Object
- TwilioRubyWrapper::Queue
- Defined in:
- lib/twilio_ruby_wrapper/queue.rb
Instance Attribute Summary collapse
-
#page_number ⇒ Object
Returns the value of attribute page_number.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
-
#queues ⇒ Object
Returns the value of attribute queues.
Instance Method Summary collapse
- #condition(value) ⇒ Object
- #find_by(*args) ⇒ Object
-
#initialize(account_sid:, auth_token:) ⇒ Queue
constructor
A new instance of Queue.
Constructor Details
#initialize(account_sid:, auth_token:) ⇒ Queue
Returns a new instance of Queue.
5 6 7 8 9 10 |
# File 'lib/twilio_ruby_wrapper/queue.rb', line 5 def initialize(account_sid:, auth_token:) client = Twilio::REST::Client.new(account_sid, auth_token) @queues = client.account.queues @page_number = 0 @page_size = 50 end |
Instance Attribute Details
#page_number ⇒ Object
Returns the value of attribute page_number.
3 4 5 |
# File 'lib/twilio_ruby_wrapper/queue.rb', line 3 def page_number @page_number end |
#page_size ⇒ Object
Returns the value of attribute page_size.
3 4 5 |
# File 'lib/twilio_ruby_wrapper/queue.rb', line 3 def page_size @page_size end |
#queues ⇒ Object
Returns the value of attribute queues.
3 4 5 |
# File 'lib/twilio_ruby_wrapper/queue.rb', line 3 def queues @queues end |
Instance Method Details
#condition(value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/twilio_ruby_wrapper/queue.rb', line 23 def condition(value) if !(Symbol === value) raise end condition = nil case value when :eq condition = -> (x) { -> (y) { y == x }} when :lt condition = -> (x) { -> (y) { y < x }} when :lteq condition = -> (x) { -> (y) { y <= x }} when :gt condition = -> (x) { -> (y) { y > x }} when :gteq condition = -> (x) { -> (y) { y >= x }} else raise end QueueCondition.new(queues: @queues, condition: condition) end |
#find_by(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/twilio_ruby_wrapper/queue.rb', line 12 def find_by(*args) hash = args.first if !(Hash === hash) || hash.values.any? {|v| v.nil? || Array === v || Hash === v } || hash.size >= 2 raise end condition = self.condition(:eq) condition.find_by(*args) end |