Expander v0.0.1 Expander.Url View Source
Defines an Expanding URL.
This module defines a Expander.Url
struct and the main functions for composing URL Expander. As it is the contract for
the public APIs of Expander it is a good idea to make use of these functions rather than build the struct yourself.
## Url fields
short_url
- the short url before expanding, example:"http://stpz.co/haddafios"
long_url
- the long url after expanding, example:"https://itunes.apple.com/us/app/haddaf-hdaf/id872585884"
## Examples
url = new() |> short_url(“http://stpz.co/haddafios”)
The composable nature makes it very easy to continue expanding upon a given url. url = url |> long_url(“https://itunes.apple.com/us/app/haddaf-hdaf/id872585884”)
You can also directly pass arguments to the new/1
function.
url = new(short_url: “http://stpz.co/haddafios”, long_url: “https://itunes.apple.com/us/app/haddaf-hdaf/id872585884”)
Link to this section Summary
Link to this section Types
Link to this section Functions
Sets the long_url
field.
The long_url must be a valid url.
Examples
iex> new() |> long_url("https://itunes.apple.com/us/app/haddaf-hdaf/id872585884")
%Expander.Url{long_url: "https://itunes.apple.com/us/app/haddaf-hdaf/id872585884", short_url: nil}
Returns a Expander.Url
struct.
You can pass a keyword list or a map argument to the function that will be used to populate the fields of that struct. Note that it will silently ignore any fields that it doesn’t know about.
Examples
iex> new()
%Expander.Url{}
iex> new(short_url: "http://stpz.co/haddafios")
%Expander.Url{short_url: "http://stpz.co/haddafios"}
iex> new(long_url: "https://itunes.apple.com/us/app/haddaf-hdaf/id872585884")
%Expander.Url{long_url: "https://itunes.apple.com/us/app/haddaf-hdaf/id872585884"}
You can obviously combine these arguments together:
iex> new(short_url: "http://stpz.co/haddafios", long_url: "https://itunes.apple.com/us/app/haddaf-hdaf/id872585884")
%Expander.Url{short_url: "http://stpz.co/haddafios", long_url: "https://itunes.apple.com/us/app/haddaf-hdaf/id872585884"}