Class: TheCity::WebHookList
- Includes:
- Enumerable
- Defined in:
- lib/api/web_hook_list.rb
Instance Attribute Summary
Attributes inherited from ApiList
#current_page, #per_page, #total_entries, #total_pages
Instance Method Summary collapse
-
#[](index) ⇒ WebHook
Get the specified web hook.
-
#all_web_hooks ⇒ Object
(also: #web_hooks)
All the web_hooks in the list.
-
#each(&block) ⇒ WebHook
This method is needed for Enumerable.
-
#empty? ⇒ Boolean
Checks if the list is empty.
-
#initialize(options = {}) ⇒ WebHookList
constructor
Constructor.
Methods inherited from ApiList
load, #next_page, #next_page!, #next_page?
Constructor Details
#initialize(options = {}) ⇒ WebHookList
Constructor.
Options:
:page - The page number to get.
:reader - The Reader to use to load the data.
Examples:
WebHookListReader.new
UserSkillList.new({:page => 2})
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/api/web_hook_list.rb', line 21 def initialize( = {}) @options = @options[:page] ||= 1 @options[:reader] = TheCity::WebHookListReader.new(@options) if @options[:reader].nil? @json_data = @options[:reader].load_feed @total_entries = @json_data['total_entries'] @total_pages = @json_data['total_pages'] @per_page = @json_data['per_page'] @current_page = @json_data['current_page'] end |
Instance Method Details
#[](index) ⇒ WebHook
Get the specified web hook.
49 50 51 |
# File 'lib/api/web_hook_list.rb', line 49 def [](index) WebHook.new( @json_data['web_hooks'][index] ) if @json_data['web_hooks'][index] end |
#all_web_hooks ⇒ Object Also known as: web_hooks
All the web_hooks in the list.
37 38 39 40 |
# File 'lib/api/web_hook_list.rb', line 37 def all_web_hooks return [] if @json_data['web_hooks'].nil? @json_data['web_hooks'].collect { |web_hook| [web_hook['object'], web_hook['event']].join('::') } end |
#each(&block) ⇒ WebHook
This method is needed for Enumerable.
57 58 59 |
# File 'lib/api/web_hook_list.rb', line 57 def each &block @json_data['web_hooks'].each{ |web_hook| yield( WebHook.new(web_hook) ) } end |
#empty? ⇒ Boolean
Checks if the list is empty.
67 68 69 |
# File 'lib/api/web_hook_list.rb', line 67 def empty? @json_data['web_hooks'].empty? end |