Sha256: 643a59d445f657462ee0cb6565e496ca2659fc00c1d72f91ffaca2879308250b

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

module PageEz
  class HasManyResult
    include DelegatesTo[:@result]

    def initialize(container:, selector:, options:, constructor:)
      @container = container
      @selector = selector
      @options = options
      @result = container.all(
        selector,
        **options
      ).map do |element|
        constructor.call(element)
      end
    end

    def has_count_of?(count)
      @container.has_css?(
        @selector,
        **@options.merge(count: count)
      )
    end

    def has_any_elements?
      @container.has_css?(
        @selector,
        **@options
      )
    end

    def has_no_elements?
      @container.has_no_css?(@selector, **@options)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_ez-0.2.0 lib/page_ez/has_many_result.rb
page_ez-0.1.0 lib/page_ez/has_many_result.rb