Alfred v0.3.1 Alfred.ResultList View Source
Represents a list of Alfred.Result
items.
Since a result list can contain other information such as variables, it is useful sometimes to create an explicit list for results.
Link to this section Summary
Link to this section Types
Link to this type
t()
View Source
t() :: %Alfred.ResultList{items: [Alfred.Result.t()], rerun: float() | nil, variables: %{optional(String.t()) => String.t()}}
Link to this section Functions
Link to this function
new(items \\ [], options \\ [])
View Source
new([Alfred.Result.t()], Keyword.t()) :: t()
Creates a new result list.
Options
:rerun
— Instructs Alfred to rerun the script every given number of seconds, must be between 1.0 and 5.0 inclusive:variables
— AMap
of variables to return with the result list
Examples
Creating a list of items:
iex> result = Alfred.Result.new("title", "subtitle")
iex> Alfred.ResultList.new([result, result, result])
%Alfred.ResultList{items: [%Alfred.Result{subtitle: "subtitle", title: "title"},
%Alfred.Result{subtitle: "subtitle", title: "title"},
%Alfred.Result{subtitle: "subtitle", title: "title"}]}
Creating a list of items and including variables:
iex> result = Alfred.Result.new("title", "subtitle")
iex> Alfred.ResultList.new([result, result, result], variables: %{foo: "bar"})
%Alfred.ResultList{items: [%Alfred.Result{subtitle: "subtitle", title: "title"},
%Alfred.Result{subtitle: "subtitle", title: "title"},
%Alfred.Result{subtitle: "subtitle", title: "title"}],
variables: %{foo: "bar"}}
Creating a list of items with variables and a rerun value:
iex> result = Alfred.Result.new("title", "subtitle")
iex> Alfred.ResultList.new([result, result, result], variables: %{foo: "bar"}, rerun: 3.0)
%Alfred.ResultList{items: [%Alfred.Result{subtitle: "subtitle", title: "title"},
%Alfred.Result{subtitle: "subtitle", title: "title"},
%Alfred.Result{subtitle: "subtitle", title: "title"}],
rerun: 3.0,
variables: %{foo: "bar"}}
Converts the given list to the expected output format.
See the Alfred documentation on the JSON output format.