Class: Mohawk::Adapters::UIA::TableRow

Inherits:
Object
  • Object
show all
Defined in:
lib/mohawk/adapters/uia/table_row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, index) ⇒ TableRow

Returns a new instance of TableRow.



7
8
9
# File 'lib/mohawk/adapters/uia/table_row.rb', line 7

def initialize(table, index)
  @table, @index = table, 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/adapters/uia/table_row.rb', line 48

def method_missing(name, *args)
  value_from_header name
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



5
6
7
# File 'lib/mohawk/adapters/uia/table_row.rb', line 5

def index
  @index
end

Instance Method Details

#addObject



24
25
26
27
# File 'lib/mohawk/adapters/uia/table_row.rb', line 24

def add
  selection_item.add_to_selection
  self
end

#all_match?(hash) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/mohawk/adapters/uia/table_row.rb', line 38

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

#cellsObject



15
16
17
# File 'lib/mohawk/adapters/uia/table_row.rb', line 15

def cells
  element.items.map &:name
end

#clearObject



29
30
31
32
# File 'lib/mohawk/adapters/uia/table_row.rb', line 29

def clear
  selection_item.remove_from_selection
  self
end

#nameObject



11
12
13
# File 'lib/mohawk/adapters/uia/table_row.rb', line 11

def name
  element.name
end

#selectObject



19
20
21
22
# File 'lib/mohawk/adapters/uia/table_row.rb', line 19

def select
  selection_item.select
  self
end

#selected?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/mohawk/adapters/uia/table_row.rb', line 34

def selected?
  selection_item.selected?
end

#to_hashObject



44
45
46
# File 'lib/mohawk/adapters/uia/table_row.rb', line 44

def to_hash
  {text: element.name, row: index}
end

#value_from_header(name) ⇒ Object

Raises:

  • (ArgumentError)


52
53
54
55
56
# File 'lib/mohawk/adapters/uia/table_row.rb', line 52

def value_from_header(name)
  which_column = header_methods.find_index {|h| h.to_s == name.to_s }
  raise ArgumentError, "#{name} column does not exist in #{header_methods}" if which_column.nil?
  cells[which_column]
end