Class: WatirCraft::Table
Class Method Summary collapse
Instance Method Summary collapse
- #elements ⇒ Object
- #fields ⇒ Object
-
#initialize(watir_table, &block) ⇒ Table
constructor
A new instance of Table.
- #row(selector) ⇒ Object
Constructor Details
#initialize(watir_table, &block) ⇒ Table
Returns a new instance of Table.
14 15 16 |
# File 'lib/watircraft/table.rb', line 14 def initialize watir_table, &block @watir_table = watir_table end |
Class Method Details
.element(name, &block) ⇒ Object
10 11 12 |
# File 'lib/watircraft/table.rb', line 10 def element(name, &block) row_class.element(name, &block) end |
.field(name, &block) ⇒ Object
7 8 9 |
# File 'lib/watircraft/table.rb', line 7 def field(name, &block) row_class.field(name, &block) end |
Instance Method Details
#elements ⇒ Object
31 32 33 |
# File 'lib/watircraft/table.rb', line 31 def elements self.class.row_class.elements.map &:to_s end |
#fields ⇒ Object
28 29 30 |
# File 'lib/watircraft/table.rb', line 28 def fields self.class.row_class.fields.map &:to_s end |
#row(selector) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/watircraft/table.rb', line 17 def row selector @watir_table.rows.each do | row | wrapped = self.class.row_class.new row # note: we are only looking at the first key/value method = selector.keys[0] target_value = selector[method] row_value = wrapped.send(method) rescue next return wrapped if row_value == target_value end nil end |