Class: AePageObjects::Collection

Inherits:
Element show all
Includes:
Enumerable
Defined in:
lib/ae_page_objects/elements/collection.rb

Constant Summary

Constants included from Node::Methods

Node::Methods::METHODS_TO_DELEGATE_TO_NODE

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Element

#parent

Instance Method Summary collapse

Methods inherited from Element

#__full_name__, #__name__, #document, #full_name, #initialize, #name, new, #to_s, #using_default_locator?

Methods included from Dsl

#collection, #element, #form_for, #inherited

Methods included from InternalHelpers

#ensure_class_for_param!

Methods included from Node::ClassMethods

#current_url, #current_url_without_params, #new_subclass

Methods included from AePageObjects::Concerns::Staleable

#node, #stale?

Methods included from AePageObjects::Concerns::LoadEnsuring

#initialize

Methods included from Node::Methods

#current_url, #current_url_without_params, #document, #initialize, #node

Constructor Details

This class inherits a constructor from AePageObjects::Element

Class Attribute Details

.item_classObject

Returns the value of attribute item_class.



8
9
10
# File 'lib/ae_page_objects/elements/collection.rb', line 8

def item_class
  @item_class
end

Instance Attribute Details

#item_locatorObject (readonly)

Returns the value of attribute item_locator.



5
6
7
# File 'lib/ae_page_objects/elements/collection.rb', line 5

def item_locator
  @item_locator
end

Instance Method Details

#[](index, &block) ⇒ Object



30
31
32
# File 'lib/ae_page_objects/elements/collection.rb', line 30

def [](index, &block)
  at(index, &block)
end

#at(index, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ae_page_objects/elements/collection.rb', line 22

def at(index, &block)
  if index >= size || index < 0
    nil
  else
    item_at(index, &block)
  end
end

#each(&block) ⇒ Object



34
35
36
37
38
# File 'lib/ae_page_objects/elements/collection.rb', line 34

def each(&block)
  (0..(size - 1)).each do |index|
    yield at(index)
  end
end

#item_classObject



18
19
20
# File 'lib/ae_page_objects/elements/collection.rb', line 18

def item_class
  self.class.item_class
end

#last(&block) ⇒ Object



44
45
46
# File 'lib/ae_page_objects/elements/collection.rb', line 44

def last(&block)
  self.at(size - 1, &block)
end

#sizeObject



40
41
42
# File 'lib/ae_page_objects/elements/collection.rb', line 40

def size
  node.all(:xpath, item_xpath).size
end