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



48
49
50
# File 'lib/mohawk/accessors/table_row.rb', line 48

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

#add_to_selectionObject



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

def add_to_selection
  row.select
  self
end

#all_match?(hash) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#cellsObject



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

def cells
  row.cells.map &:text
end

#clearObject



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

def clear
  row.clear
  self
end

#selectObject



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

def select
  UiaDll::table_single_select(@table.view.search_information, row.row)
  self
end

#selected?Boolean

Returns:

  • (Boolean)


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

def selected?
  row.selected?
end

#to_hashObject



52
53
54
# File 'lib/mohawk/accessors/table_row.rb', line 52

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

#value_from_header(name) ⇒ Object

Raises:

  • (ArgumentError)


42
43
44
45
46
# File 'lib/mohawk/accessors/table_row.rb', line 42

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