Class: PageObject::SectionCollection
- Inherits:
-
Object
- Object
- PageObject::SectionCollection
- Includes:
- Enumerable
- Defined in:
- lib/page-object/sections.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #find_by(values_hash) ⇒ Object
-
#initialize(sections) ⇒ SectionCollection
constructor
A new instance of SectionCollection.
- #select_by(values_hash) ⇒ Object
Constructor Details
#initialize(sections) ⇒ SectionCollection
Returns a new instance of SectionCollection.
5 6 7 |
# File 'lib/page-object/sections.rb', line 5 def initialize sections @sections = sections end |
Instance Method Details
#[](index) ⇒ Object
13 14 15 |
# File 'lib/page-object/sections.rb', line 13 def [] index @sections[index] end |
#each(&block) ⇒ Object
9 10 11 |
# File 'lib/page-object/sections.rb', line 9 def each &block @sections.each &block end |
#find_by(values_hash) ⇒ Object
17 18 19 20 21 |
# File 'lib/page-object/sections.rb', line 17 def find_by values_hash @sections.find {|section| values_hash.all? {|method,value| value === section.public_send(method)} } end |
#select_by(values_hash) ⇒ Object
23 24 25 26 27 |
# File 'lib/page-object/sections.rb', line 23 def select_by values_hash SectionCollection.new @sections.select {|section| values_hash.all? {|method,value| value === section.public_send(method)} } end |