Class: Aws::Resources::Collection
- Inherits:
-
Object
- Object
- Aws::Resources::Collection
- Includes:
- Enumerable
- Defined in:
- gems/aws-sdk-core/lib/aws-sdk-core/resources/collection.rb
Direct Known Subclasses
AutoScaling::Activity::Collection, AutoScaling::AutoScalingGroup::Collection, AutoScaling::Instance::Collection, AutoScaling::LaunchConfiguration::Collection, AutoScaling::LifecycleHook::Collection, AutoScaling::LoadBalancer::Collection, AutoScaling::NotificationConfiguration::Collection, AutoScaling::ScalingPolicy::Collection, AutoScaling::ScheduledAction::Collection, AutoScaling::Tag::Collection, CloudFormation::Event::Collection, CloudFormation::Stack::Collection, CloudFormation::StackResource::Collection, CloudFormation::StackResourceSummary::Collection, CloudWatch::Alarm::Collection, CloudWatch::CompositeAlarm::Collection, CloudWatch::Metric::Collection, DynamoDB::Table::Collection, EC2::ClassicAddress::Collection, EC2::DhcpOptions::Collection, EC2::Image::Collection, EC2::Instance::Collection, EC2::InternetGateway::Collection, EC2::KeyPair::Collection, EC2::KeyPairInfo::Collection, EC2::NatGateway::Collection, EC2::NetworkAcl::Collection, EC2::NetworkInterface::Collection, EC2::NetworkInterfaceAssociation::Collection, EC2::PlacementGroup::Collection, EC2::Route::Collection, EC2::RouteTable::Collection, EC2::RouteTableAssociation::Collection, EC2::SecurityGroup::Collection, EC2::Snapshot::Collection, EC2::Subnet::Collection, EC2::Tag::Collection, EC2::Volume::Collection, EC2::Vpc::Collection, EC2::VpcAddress::Collection, EC2::VpcPeeringConnection::Collection, Glacier::Account::Collection, Glacier::Archive::Collection, Glacier::Job::Collection, Glacier::MultipartUpload::Collection, Glacier::Notification::Collection, Glacier::Vault::Collection, IAM::AccessKey::Collection, IAM::AccessKeyPair::Collection, IAM::AccountPasswordPolicy::Collection, IAM::AccountSummary::Collection, IAM::AssumeRolePolicy::Collection, IAM::CurrentUser::Collection, IAM::Group::Collection, IAM::GroupPolicy::Collection, IAM::InstanceProfile::Collection, IAM::LoginProfile::Collection, IAM::MfaDevice::Collection, IAM::Policy::Collection, IAM::PolicyVersion::Collection, IAM::Role::Collection, IAM::RolePolicy::Collection, IAM::SamlProvider::Collection, IAM::ServerCertificate::Collection, IAM::SigningCertificate::Collection, IAM::User::Collection, IAM::UserPolicy::Collection, IAM::VirtualMfaDevice::Collection, OpsWorks::Layer::Collection, OpsWorks::Stack::Collection, OpsWorks::StackSummary::Collection, Aws::RDS::AccountQuota::Collection, Aws::RDS::Certificate::Collection, Aws::RDS::DBCluster::Collection, Aws::RDS::DBClusterParameterGroup::Collection, Aws::RDS::DBClusterSnapshot::Collection, Aws::RDS::DBEngine::Collection, Aws::RDS::DBEngineVersion::Collection, Aws::RDS::DBInstance::Collection, Aws::RDS::DBLogFile::Collection, Aws::RDS::DBParameterGroup::Collection, Aws::RDS::DBParameterGroupFamily::Collection, Aws::RDS::DBSecurityGroup::Collection, Aws::RDS::DBSnapshot::Collection, Aws::RDS::DBSnapshotAttribute::Collection, Aws::RDS::DBSubnetGroup::Collection, Aws::RDS::Event::Collection, Aws::RDS::EventCategoryMap::Collection, Aws::RDS::EventSubscription::Collection, Aws::RDS::OptionGroup::Collection, Aws::RDS::OptionGroupOption::Collection, Aws::RDS::Parameter::Collection, Aws::RDS::PendingMaintenanceAction::Collection, Aws::RDS::ReservedDBInstance::Collection, Aws::RDS::ReservedDBInstancesOffering::Collection, Aws::RDS::ResourcePendingMaintenanceActionList::Collection, S3::Bucket::Collection, S3::BucketAcl::Collection, S3::BucketCors::Collection, S3::BucketLifecycle::Collection, S3::BucketLifecycleConfiguration::Collection, S3::BucketLogging::Collection, S3::BucketNotification::Collection, S3::BucketPolicy::Collection, S3::BucketRequestPayment::Collection, S3::BucketTagging::Collection, S3::BucketVersioning::Collection, S3::BucketWebsite::Collection, S3::MultipartUpload::Collection, S3::MultipartUploadPart::Collection, S3::Object::Collection, S3::ObjectAcl::Collection, S3::ObjectSummary::Collection, S3::ObjectVersion::Collection, SNS::PlatformApplication::Collection, SNS::PlatformEndpoint::Collection, SNS::Subscription::Collection, SNS::Topic::Collection, SQS::Message::Collection, SQS::Queue::Collection
Instance Method Summary collapse
-
#each(&block) ⇒ Enumerator<Band>
-
#first(count = nil) ⇒ Resource, Collection
-
#limit(limit) ⇒ Collection
Returns a new collection that will enumerate a limited number of items.
-
#size ⇒ Integer?
(also: #length)
Returns the size of this collection if known, returns
nil
when an API call is necessary to enumerate items in this collection.
Instance Method Details
#each(&block) ⇒ Enumerator<Band>
50 51 52 53 54 55 56 57 58 59 60 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/resources/collection.rb', line 50 def each(&block) enum = ::Enumerator.new do |y| batch_enum.each do |batch| batch.each do |band| y.yield(band) end end end enum.each(&block) if block enum end |
#first(count = nil) ⇒ Resource, Collection
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/resources/collection.rb', line 64 def first(count = nil) if count items = limit(count).to_a self.class.new([items], size: items.size) else begin each.next rescue StopIteration nil end end end |
#limit(limit) ⇒ Collection
Returns a new collection that will enumerate a limited number of items.
collection.limit(10).each do |band|
# yields at most 10 times
end
85 86 87 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/resources/collection.rb', line 85 def limit(limit) Collection.new(@batches, limit: limit) end |
#size ⇒ Integer? Also known as: length
Returns the size of this collection if known, returns nil
when
an API call is necessary to enumerate items in this collection.
23 24 25 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/resources/collection.rb', line 23 def size @size end |