Class: FellowshipOne::ContributionList
- Inherits:
-
Object
- Object
- FellowshipOne::ContributionList
- Includes:
- Enumerable
- Defined in:
- lib/api/contribution_list.rb
Instance Attribute Summary collapse
-
#additional_pages ⇒ Object
readonly
Returns the value of attribute additional_pages.
-
#count ⇒ Object
(also: #size)
readonly
Returns the value of attribute count.
-
#page_number ⇒ Object
readonly
Returns the value of attribute page_number.
-
#total_records ⇒ Object
readonly
Returns the value of attribute total_records.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Get the specified contribution.
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
-
#empty? ⇒ Boolean
Checks if the list is empty.
-
#initialize(options) ⇒ ContributionList
constructor
Constructor.
Constructor Details
#initialize(options) ⇒ ContributionList
Constructor.
Options: :page - (optional) The page number to get. :reader - (optional) The Reader to use to load the data.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/api/contribution_list.rb', line 17 def initialize() #options[:page] ||= 1 reader = [:reader] || FellowshipOne::ContributionListReader.new() @json_data = reader.load_feed @count = @json_data['@count'].to_i @page_number = @json_data['@pageNumber'].to_i @total_records = @json_data['@totalRecords'].to_i @additional_pages = @json_data['@additionalPages'].to_i end |
Instance Attribute Details
#additional_pages ⇒ Object (readonly)
Returns the value of attribute additional_pages.
7 8 9 |
# File 'lib/api/contribution_list.rb', line 7 def additional_pages @additional_pages end |
#count ⇒ Object (readonly) Also known as: size
Returns the value of attribute count.
7 8 9 |
# File 'lib/api/contribution_list.rb', line 7 def count @count end |
#page_number ⇒ Object (readonly)
Returns the value of attribute page_number.
7 8 9 |
# File 'lib/api/contribution_list.rb', line 7 def page_number @page_number end |
#total_records ⇒ Object (readonly)
Returns the value of attribute total_records.
7 8 9 |
# File 'lib/api/contribution_list.rb', line 7 def total_records @total_records end |
Instance Method Details
#[](index) ⇒ Object
Get the specified contribution.
34 35 36 |
# File 'lib/api/contribution_list.rb', line 34 def [](index) Contribution.new( @json_data['contributionReceipt'][index] ) if @json_data['contributionReceipt'][index] end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
40 41 42 |
# File 'lib/api/contribution_list.rb', line 40 def each &block @json_data['contributionReceipt'].each{ |cont_recpt| yield( Contribution.new(cont_recpt) )} end |
#empty? ⇒ Boolean
Checks if the list is empty.
51 52 53 |
# File 'lib/api/contribution_list.rb', line 51 def empty? self.count == 0 ? true : false end |