Class: TheCity::SkilledUserIdList
- Includes:
- Enumerable
- Defined in:
- lib/api/skilled_user_id_list.rb
Instance Attribute Summary
Attributes inherited from ApiList
#current_page, #per_page, #total_entries, #total_pages
Instance Method Summary collapse
-
#[](index) ⇒ User
Get the specified skill.
-
#all_user_ids ⇒ Object
(also: #user_ids)
All the user ids in the list.
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
-
#empty? ⇒ Boolean
Checks if the list is empty.
-
#initialize(options = {}) ⇒ SkilledUserIdList
constructor
Constructor.
Methods inherited from ApiList
load, #next_page, #next_page!, #next_page?
Constructor Details
#initialize(options = {}) ⇒ SkilledUserIdList
Constructor.
Options:
:skill_id - The skill ID to load the user for. (Required)
:page - The page number to get.
Examples:
SkilledUserList.new
SkilledUserList.new({:page => 2})
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/api/skilled_user_id_list.rb', line 21 def initialize( = {}) @options = @options[:page] ||= 1 @options[:reader] = TheCity::SkilledUserIdListReader.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) ⇒ User
Get the specified skill.
49 50 51 |
# File 'lib/api/skilled_user_id_list.rb', line 49 def [](index) @json_data['user_ids'][index] if @json_data['user_ids'][index] end |
#all_user_ids ⇒ Object Also known as: user_ids
All the user ids in the list.
37 38 39 40 |
# File 'lib/api/skilled_user_id_list.rb', line 37 def all_user_ids return [] if @json_data['user_ids'].nil? @json_data['user_ids'].collect { |user_id| user_id } end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
55 56 57 |
# File 'lib/api/skilled_user_id_list.rb', line 55 def each &block @json_data['user_ids'].each{ |user_id| yield( user_id )} end |
#empty? ⇒ Boolean
Checks if the list is empty.
66 67 68 |
# File 'lib/api/skilled_user_id_list.rb', line 66 def empty? @json_data['user_ids'].empty? end |