Class: Gamera::PageSections::TableRow

Inherits:
Capybara::Node::Element
  • Object
show all
Defined in:
lib/gamera/page_sections/table.rb

Overview

Default class used to represent a row in a table

Instance Method Summary collapse

Constructor Details

#initialize(row_css, headers) ⇒ TableRow

Returns a new instance of TableRow.

Parameters:

  • row_css (String)

    The css selector for the row

  • headers (Array)

    An array of the strings from the tables header row



222
223
224
225
226
227
228
229
230
231
# File 'lib/gamera/page_sections/table.rb', line 222

def initialize(row_css, headers)
  super(row_css)

  headers.each_with_index do |header, i|
    cell_name = header.downcase.tr(' ', '_').gsub(/[^a-z0-9_]+/, '')
    self.class.send(:define_method, cell_name) do
      find("td:nth-child(#{i + 1})").text
    end
  end
end