View Source ROR.Filter (ROR v0.1.0)

A structure for building simple ROR Filter strings

Summary

Functions

Creates a new Filter struct from a map or keyword list.

Converts a Filter struct to a ROR filter string

Types

t()

@type t() :: %ROR.Filter{
  continent_code: binary() | atom(),
  continent_name: binary() | atom(),
  country_code: binary() | atom(),
  country_name: binary() | atom(),
  status: binary() | atom(),
  types: binary() | atom()
}

Functions

new(filter \\ [])

@spec new(input :: t() | keyword() | map()) :: t()

Creates a new Filter struct from a map or keyword list.

Keys that can be passed are: :status, :types, :country_code, :country_name, :continent_code, :continent_name and also :type, which is corrected to :types.

Passing an existing Filter struct returns the same struct

Example

iex> ROR.Filter.new(types: "funder", country_code: "DE")
%ROR.Filter{
  status: nil,
  types: "funder",
  country_code: "DE",
  country_name: nil,
  continent_code: nil,
  continent_name: nil
}

to_ror_param(filter)

@spec to_ror_param(filter :: t() | keyword()) :: nil | binary()

Converts a Filter struct to a ROR filter string

Example

iex> ROR.Filter.new(types: "funder", country_code: "DE")
...> |> ROR.Filter.to_ror_param()
"types:funder,locations.geonames_details.country_code:DE"