Class: ChurchCommunityBuilder::FundList
- Includes:
- Enumerable
- Defined in:
- lib/api/fund_list.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#funds_array ⇒ Object
readonly
Returns the value of attribute funds_array.
-
#json_data ⇒ Object
readonly
Returns the value of attribute json_data.
Attributes inherited from ApiObject
#error_messages, #marked_for_destruction
Instance Method Summary collapse
- #[](index) ⇒ Object
- #all_names ⇒ Object
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
- #empty? ⇒ Boolean
- #ids ⇒ Object
-
#initialize(json) ⇒ FundList
constructor
A new instance of FundList.
Methods inherited from ApiObject
__ccb_attributes, ccb_attr_accessor, #initialize_from_json_object, #is_deleted?, #set_attributes, #to_attributes
Constructor Details
#initialize(json) ⇒ FundList
Returns a new instance of FundList.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/api/fund_list.rb', line 11 def initialize(json) #funds_json = json_data['ccb_api']['response']['transaction_detail_types']['transaction_detail_type'] @json_data = json['ccb_api'] funds = @json_data['response']['transaction_detail_types'] @count = funds['count'].to_i #number of records # if funds['transaction_detail_type'] is a single item, it will be returned # as a Hash, rather than a single element Array, containing the Hash. if funds['transaction_detail_type'].is_a?(Array) @funds_array = funds['transaction_detail_type'] elsif funds['transaction_detail_type'].is_a?(Hash) @funds_array = [] @funds_array << funds['transaction_detail_type'] #array of each funds end end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/api/fund_list.rb', line 7 def count @count end |
#funds_array ⇒ Object (readonly)
Returns the value of attribute funds_array.
7 8 9 |
# File 'lib/api/fund_list.rb', line 7 def funds_array @funds_array end |
#json_data ⇒ Object (readonly)
Returns the value of attribute json_data.
7 8 9 |
# File 'lib/api/fund_list.rb', line 7 def json_data @json_data end |
Instance Method Details
#[](index) ⇒ Object
36 37 38 |
# File 'lib/api/fund_list.rb', line 36 def [](index) Fund.new( @funds_array[index] ) if @funds_array and @funds_array[index] end |
#all_names ⇒ Object
27 28 29 30 |
# File 'lib/api/fund_list.rb', line 27 def all_names return [] unless @funds_array @funds_array.collect { |fund| fund['name'] } end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
42 43 44 |
# File 'lib/api/fund_list.rb', line 42 def each &block @funds_array.each{ |fund| yield( Fund.new(fund) )} end |
#empty? ⇒ Boolean
47 48 49 |
# File 'lib/api/fund_list.rb', line 47 def empty? @funds_array.size == 0 ? true : false end |
#ids ⇒ Object
32 33 34 |
# File 'lib/api/fund_list.rb', line 32 def ids (@funds_array.collect { |fund| fund['id'].to_i }).uniq end |