Class: TheCity::UserFamilyList
- Includes:
- Enumerable
- Defined in:
- lib/api/user_family_list.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from ApiList
#current_page, #per_page, #total_entries, #total_pages
Instance Method Summary collapse
-
#[](index) ⇒ UserFamilyMember
Get the specified family member.
-
#all_names ⇒ Object
(also: #names)
All the famly member names in the list.
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
-
#empty? ⇒ Boolean
Checks if the list is empty.
-
#initialize(options = {}) ⇒ UserFamilyList
constructor
Constructor.
Methods inherited from ApiList
load, #next_page, #next_page!, #next_page?
Constructor Details
#initialize(options = {}) ⇒ UserFamilyList
Constructor.
Options:
:user_id - The ID of the user to load the family members for. (required)
:page - The page number to get.
:reader - The Reader to use to load the data.
Examples:
UserFamilyList.new({:user_id => 12345})
UserFamilyList.new({:user_id => 12345, :page => 2})
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/api/user_family_list.rb', line 24 def initialize( = {}) @options = @options[:page] ||= 1 @options[:reader] = TheCity::UserFamilyListReader.new(@options) if @options[:reader].nil? @json_data = @options[:reader].load_feed @id = @json_data['id'] @created_at = @json_data['created_at'] @external_id = @json_data['external_id'] end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
7 8 9 |
# File 'lib/api/user_family_list.rb', line 7 def created_at @created_at end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
7 8 9 |
# File 'lib/api/user_family_list.rb', line 7 def external_id @external_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/api/user_family_list.rb', line 7 def id @id end |
Instance Method Details
#[](index) ⇒ UserFamilyMember
Get the specified family member.
50 51 52 |
# File 'lib/api/user_family_list.rb', line 50 def [](index) UserFamilyMember.new( @json_data['family_members'][index] ) if @json_data['family_members'][index] end |
#all_names ⇒ Object Also known as: names
All the famly member names in the list.
39 40 41 |
# File 'lib/api/user_family_list.rb', line 39 def all_names @json_data['family_members'].collect { |user| user['name'] } end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
56 57 58 |
# File 'lib/api/user_family_list.rb', line 56 def each &block @json_data['family_members'].each{ |member| yield( UserFamilyMember.new(member) )} end |
#empty? ⇒ Boolean
Checks if the list is empty.
66 67 68 |
# File 'lib/api/user_family_list.rb', line 66 def empty? @json_data['family_members'].empty? end |