defmodule Wallaby.XPath.Builder do def descendants(list) when is_list(list) do list |> Enum.map(&descendant/1) end def descendant(item) when is_binary(item) do {:descendant, item} end def union(nodes, predicate) do {:union, nodes, predicate} end def all(list) when is_list(list) do {:and, list} end def any(list) when is_list(list) do {:any, list} end @doc """ Returns a list of noted values. iex> Wallaby.XPath.exclude(["a", "b", "c"]) {:not, ["a", "b", "c"]} """ def none(exclusions), do: {:not, exclusions} @doc """ Returns a list of tuples with the attribute and value of the list iex> attr("type", ["checkbox", "submit"]) [{"type", "checkbox"}, {"type", "submit"}] """ def attr(a, list) when is_list(list) do list |> Enum.map(&attr(a, &1)) end def attr(a, item) when is_binary(item) do {:attr, a, item} end end