Class: ChurchCommunityBuilder::BatchList
- Inherits:
-
Object
- Object
- ChurchCommunityBuilder::BatchList
- Includes:
- Enumerable
- Defined in:
- lib/api/batch_list.rb
Instance Attribute Summary collapse
-
#availability ⇒ Object
readonly
Returns the value of attribute availability.
-
#batch_array ⇒ Object
readonly
Returns the value of attribute batch_array.
-
#batches ⇒ Object
readonly
Returns the value of attribute batches.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#json_data ⇒ Object
readonly
Returns the value of attribute json_data.
-
#request_data ⇒ Object
readonly
Returns the value of attribute request_data.
-
#response_data ⇒ Object
readonly
Returns the value of attribute response_data.
-
#service_action ⇒ Object
readonly
Returns the value of attribute service_action.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #all_names ⇒ Object
-
#each(&block) ⇒ Object
This method is needed for Enumerable.
- #empty? ⇒ Boolean
-
#initialize(json) ⇒ BatchList
constructor
A new instance of BatchList.
Constructor Details
#initialize(json) ⇒ BatchList
Returns a new instance of BatchList.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/api/batch_list.rb', line 16 def initialize(json) @json_data = json['ccb_api'] @request_data = @json_data['request'] # This is needed for now to account for the two different formats @batches = if @json_data.has_key?('response') @response_data = @json_data['response'] @service = @response_data['service_action'] #CCB service type accessed @availability = @response_data['availability'] # @batches = @response_data['batches'] @response_data['batches'] else @json_data['batches'] end @count = @batches['count'].to_i #number of records @batch_array = @batches['batch'].class == Array ? @batches['batch'] : [@batches['batch']].compact #array of each batch end |
Instance Attribute Details
#availability ⇒ Object (readonly)
Returns the value of attribute availability.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def availability @availability end |
#batch_array ⇒ Object (readonly)
Returns the value of attribute batch_array.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def batch_array @batch_array end |
#batches ⇒ Object (readonly)
Returns the value of attribute batches.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def batches @batches end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def count @count end |
#json_data ⇒ Object (readonly)
Returns the value of attribute json_data.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def json_data @json_data end |
#request_data ⇒ Object (readonly)
Returns the value of attribute request_data.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def request_data @request_data end |
#response_data ⇒ Object (readonly)
Returns the value of attribute response_data.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def response_data @response_data end |
#service_action ⇒ Object (readonly)
Returns the value of attribute service_action.
7 8 9 |
# File 'lib/api/batch_list.rb', line 7 def service_action @service_action end |
Instance Method Details
#[](index) ⇒ Object
40 41 42 |
# File 'lib/api/batch_list.rb', line 40 def [](index) Batch.new( @batch_array[index] ) if @batch_array and @batch_array[index] end |
#all_names ⇒ Object
35 36 37 38 |
# File 'lib/api/batch_list.rb', line 35 def all_names return [] unless @batch_array @batch_array.collect { |batch| [batch['first_name'], batch['last_name']].join(' ') } end |
#each(&block) ⇒ Object
This method is needed for Enumerable.
46 47 48 |
# File 'lib/api/batch_list.rb', line 46 def each &block @batch_array.each{ |batch| yield( Batch.new(batch) )} end |
#empty? ⇒ Boolean
51 52 53 |
# File 'lib/api/batch_list.rb', line 51 def empty? self.count == 0 ? true : false end |