Sha256: 5e9ce9426af187646036fa51f8bb1a9b5f43af55372d7c9f4fb8cc2e3895f378
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
module WatirCraft class Table class << self def row_class @row_class ||= Class.new(Row) end def field(name, &block) row_class.field(name, &block) end def element(name, &block) row_class.element(name, &block) end end def initialize watir_table, &block @watir_table = watir_table end 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 def fields self.class.row_class.fields.map &:to_s end def elements self.class.row_class.elements.map &:to_s end end class Row class << self def element name, &block elements << name define_method(name) do instance_eval &block end end def elements # :nodoc: @elements ||= [] end def field name, &block fields << name element_name = "#{name}_field" element element_name, &block define_method(name) do send(element_name).display_value end define_method("#{name}=") do | value | send(element_name).set value end end def fields # :nodoc: @fields ||= [] end end attr_reader :row def initialize watir_row @row = watir_row end # Returns true. If the row doesn't exist, you'll get nil as the return # value of Table#row. def exist? true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bret-watircraft-0.5.0 | lib/watircraft/table.rb |