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


205
206
207
208
209
210
211
212
213
214
# File 'lib/gamera/page_sections/table.rb', line 205

def initialize(row_css, headers)
  super(row_css)

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