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__, #browser, #document, #full_name, #initialize, #name, #to_s, #using_default_locator?, #window

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) ⇒ Object



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

def [](index)
  at(index)
end

#at(index) ⇒ Object



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

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

#eachObject



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

def each
  (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

#lastObject



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

def last
  self.at(size - 1)
end

#sizeObject



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

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