Class: FellowshipOne::MemberHouseholdList
- Inherits:
-
Object
- Object
- FellowshipOne::MemberHouseholdList
- Includes:
- Enumerable
- Defined in:
- lib/api/member_household_list.rb
Instance Method Summary collapse
-
#[](index) ⇒ User
Get the specified user.
- #all_names ⇒ Object
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
-
#empty? ⇒ Boolean
Checks if the list is empty.
-
#ids ⇒ Object
Get all the household ids in the list.
-
#initialize(options) ⇒ MemberHouseholdList
constructor
Constructor.
-
#raw_data ⇒ Object
Access to the raw JSON data.
Constructor Details
#initialize(options) ⇒ MemberHouseholdList
Constructor.
Options: :page - (optional) The page number to get. :reader - (optional) The Reader to use to load the data. :household_id - The household ID to pull the info for.
15 16 17 18 19 20 21 |
# File 'lib/api/member_household_list.rb', line 15 def initialize() raise 'Household ID not specified' if [:household_id].nil? #options[:page] ||= 1 reader = [:reader] || FellowshipOne::MemberHouseholdListReader.new() @json_data = reader.load_feed end |
Instance Method Details
#[](index) ⇒ User
Get the specified user.
30 31 32 |
# File 'lib/api/member_household_list.rb', line 30 def [](index) Person.new( @json_data['people']['person'][index] ) if @json_data['people']['person'] and @json_data['people']['person'][index] end |
#all_names ⇒ Object
34 35 36 37 |
# File 'lib/api/member_household_list.rb', line 34 def all_names return [] unless @json_data['people'] @json_data['people']['person'].collect { |person| [person['firstName'], person['lastName']].join(' ') } end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
40 41 42 |
# File 'lib/api/member_household_list.rb', line 40 def each &block @json_data['people']['person'].each{ |person| yield( Person.new(person) )} end |
#empty? ⇒ Boolean
Checks if the list is empty.
50 51 52 53 |
# File 'lib/api/member_household_list.rb', line 50 def empty? #@json_data['person'].empty? self.count == 0 ? true : false end |
#ids ⇒ Object
Get all the household ids in the list.
58 59 60 |
# File 'lib/api/member_household_list.rb', line 58 def ids @json_data['people']['person'].collect { |person| person['@id'] } end |
#raw_data ⇒ Object
Access to the raw JSON data. This method is needed for merging lists.
65 66 67 |
# File 'lib/api/member_household_list.rb', line 65 def raw_data @json_data['people']['person'] end |