Sha256: dcabad12e983aaafec1936db9672efa9fb33887aa523114cb9260bd28ad22eff

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

module Mohawk
  module Accessors
    class Table
      attr_reader :view

      include Enumerable

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

      def select(which_item)
        case which_item
          when Hash
            select_by_hash(which_item)
          else
            select_by_value(which_item)
        end
      end

      def find_row_with(row_info)
        found_row = find { |r| r.all_match? row_info }
        raise "A row with #{row_info} was not found" unless found_row
        found_row
      end

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

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

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

      private
      def select_by_value(which_item)
        view.select which_item
      end

      def select_by_hash(which_item)
        found_row = find_row_with(which_item)
        found_row.select
        found_row
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mohawk-0.0.9 lib/mohawk/accessors/table.rb
mohawk-0.0.8 lib/mohawk/accessors/table.rb
mohawk-0.0.7 lib/mohawk/accessors/table.rb
mohawk-0.0.6 lib/mohawk/accessors/table.rb