Sha256: d7a8f30b767f34523d3c36a15738408f53068eab0fa782cf19bdb2295eed46ba

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

module PageObject
  module IndexedProperties
    class TableOfElements
      include PageObject

      def initialize (browser, identifier_list)
        initialize_browser(browser)
        @identifier_list = identifier_list
        @indexed_property_class = Class.new {
          include PageObject
          extend Accessors

          def initialize (browser, index, identifier_list)
            initialize_browser(browser)

            identifier_list.each do |identifier|
              type = identifier[0]
              name = identifier[1]
              how_and_what = identifier[2].clone # Cannot modify the original...
              how_and_what.each do |key, value|
                next if value.is_a? Regexp # Cannot format Regexp with %
                if key == :index
                  how_and_what[key] = (value % index).to_i
                elsif key == :frame
                  how_and_what[key] = value #passthrough frame without modification
                else
                  how_and_what[key] = value % index
                end
              end
              self.class.send type, name, how_and_what unless Class.instance_methods.include? name
            end
          end
        }
      end

      def [] (index)
        @indexed_property_class.new(@browser, index, @identifier_list)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
page-object-2.2.6 lib/page-object/indexed_properties.rb
page-object-2.2.5 lib/page-object/indexed_properties.rb
page-object-2.2.4 lib/page-object/indexed_properties.rb
page-object-2.2.3 lib/page-object/indexed_properties.rb
page-object-2.2.2 lib/page-object/indexed_properties.rb
page-object-2.2.1 lib/page-object/indexed_properties.rb
page-object-2.2 lib/page-object/indexed_properties.rb