Class: Mohawk::Accessors::Table

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mohawk/accessors/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, locator) ⇒ Table

Returns a new instance of Table.



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

def initialize(adapter, locator)
  @view = adapter.window.table(locator)
end

Instance Attribute Details

#viewObject (readonly)

Returns the value of attribute view.



4
5
6
# File 'lib/mohawk/accessors/table.rb', line 4

def view
  @view
end

Instance Method Details

#[](row) ⇒ Object



45
46
47
# File 'lib/mohawk/accessors/table.rb', line 45

def [](row)
  TableRow.new(self, row)
end

#add(which_item) ⇒ Object



16
17
18
# File 'lib/mohawk/accessors/table.rb', line 16

def add(which_item)
  find_row_with(which_item).add_to_selection
end

#clear(which_item) ⇒ Object



24
25
26
# File 'lib/mohawk/accessors/table.rb', line 24

def clear(which_item)
  find_row_with(which_item).clear
end

#clear_allObject



20
21
22
# File 'lib/mohawk/accessors/table.rb', line 20

def clear_all
  view.selected_rows.each(&:clear)
end

#eachObject



49
50
51
52
53
# File 'lib/mohawk/accessors/table.rb', line 49

def each
  view.row_count.times.map do |row|
    yield TableRow.new(self, row)
  end
end

#find_row_with(row_info) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mohawk/accessors/table.rb', line 28

def find_row_with(row_info)
  found_row = case row_info
                when Hash
                  find_by_hash(row_info)
                when Fixnum
                  find_by_index(row_info)
                when String
                  find_by_value(row_info)
              end
  raise "A row with #{row_info} was not found" unless found_row
  found_row
end

#headersObject



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

def headers
  RAutomation::Adapter::MsUia::UiaDll.table_headers(view.search_information)
end

#select(which_item) ⇒ Object



12
13
14
# File 'lib/mohawk/accessors/table.rb', line 12

def select(which_item)
  find_row_with(which_item).select
end