class Playwright::SelectOptionValues

Public Class Methods

new(element: nil, index: nil, value: nil, label: nil) click to toggle source
# File lib/playwright/select_option_values.rb, line 3
def initialize(element: nil, index: nil, value: nil, label: nil)
  params = {}

  options = []
  if value
    options.concat(convert(:value, value))
  end

  if index
    options.concat(convert(:index, index))
  end

  if label
    options.concat(convert(:label, label))
  end

  unless options.empty?
    params[:options] = options
  end

  if element
    params[:elements] = convert(:element, element)
  end

  @params = params
end

Public Instance Methods

as_params() click to toggle source

@return [Hash]

# File lib/playwright/select_option_values.rb, line 31
def as_params
  @params
end

Private Instance Methods

convert(key, values) click to toggle source
# File lib/playwright/select_option_values.rb, line 35
        def convert(key, values)
  return convert(key, [values]) unless values.is_a?(Enumerable)
  return [] if values.empty?
  values.each_with_index do |value, index|
    unless value
      raise ArgumentError.new("options[#{index}]: expected object, got null")
    end
  end

  if key == :element
    values.map(&:channel)
  else
    values.map { |value| { key => value } }
  end
end