Class: Mohawk::Accessors::TableRow

Inherits:
Object
  • Object
show all
Includes:
RAutomation::Adapter::MsUia
Defined in:
lib/mohawk/accessors/table_row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, row_index) ⇒ TableRow

Returns a new instance of TableRow.



8
9
10
11
# File 'lib/mohawk/accessors/table_row.rb', line 8

def initialize(table, row_index)
  @table = table
  @row = Row.new(@table.view, :index => row_index)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



37
38
39
# File 'lib/mohawk/accessors/table_row.rb', line 37

def method_missing(name, *args)
  value_from_header name
end

Instance Attribute Details

#rowObject (readonly)

Returns the value of attribute row.



6
7
8
# File 'lib/mohawk/accessors/table_row.rb', line 6

def row
  @row
end

Instance Method Details

#all_match?(hash) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/mohawk/accessors/table_row.rb', line 25

def all_match?(hash)
  hash.all? do |key, value|
    send(key) == "#{value}"
  end
end

#cellsObject



21
22
23
# File 'lib/mohawk/accessors/table_row.rb', line 21

def cells
  row.cells.map &:text
end

#selectObject



17
18
19
# File 'lib/mohawk/accessors/table_row.rb', line 17

def select
  @table.view.select row.row
end

#selected?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/mohawk/accessors/table_row.rb', line 13

def selected?
  @table.view.selected? row.row
end

#to_hashObject



41
42
43
# File 'lib/mohawk/accessors/table_row.rb', line 41

def to_hash
  {:text => row.text, :row => row.row }
end

#value_from_header(name) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/mohawk/accessors/table_row.rb', line 31

def value_from_header(name)
  which_column = header_methods.index(name)
  raise ArgumentError, "#{name} column does not exist in #{header_methods}" if which_column.nil?
  Cell.new(row, :index => which_column).text
end