Class: SparklingWatir::ElementCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sparkling_watir/element_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver, selector) ⇒ ElementCollection



9
10
11
12
13
# File 'lib/sparkling_watir/element_collection.rb', line 9

def initialize(driver, selector)
  @driver = driver
  @selector = selector
  @collection = create_collection
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



7
8
9
# File 'lib/sparkling_watir/element_collection.rb', line 7

def driver
  @driver
end

#selectorObject (readonly)

Returns the value of attribute selector.



7
8
9
# File 'lib/sparkling_watir/element_collection.rb', line 7

def selector
  @selector
end

Instance Method Details

#[](value) ⇒ Object



37
38
39
# File 'lib/sparkling_watir/element_collection.rb', line 37

def [](value)
  @collection[value]
end

#add(element) ⇒ Object



15
16
17
# File 'lib/sparkling_watir/element_collection.rb', line 15

def add(element)
  @collection << element
end

#eachObject



19
20
21
22
23
# File 'lib/sparkling_watir/element_collection.rb', line 19

def each
  @collection.each do |element|
    yield element
  end
end

#firstObject



41
42
43
# File 'lib/sparkling_watir/element_collection.rb', line 41

def first
  @collection.first
end

#lastObject



45
46
47
# File 'lib/sparkling_watir/element_collection.rb', line 45

def last
  @collection.last
end

#to_aObject



33
34
35
# File 'lib/sparkling_watir/element_collection.rb', line 33

def to_a
  @collection
end