xkcd v0.0.3 Xkcd

A client for the XKCD JSON API

Summary

Functions

Gets the latest comic and returns a tuple with :ok and a comic struct

Takes a number from 1 to the latest and returns a tuple with with :ok and a comic struct or an :error atom and an error message

Gets a random comic and returns a tuple with :ok and a comic struct

Functions

latest()

Specs

latest :: {:ok, Xkcd.Comic.t}

Gets the latest comic and returns a tuple with :ok and a comic struct

Example:

iex> Xkcd.latest
{:ok, %Xkcd.Comic{...}}
number(integer)

Specs

number(integer) ::
  {:ok, Xkcd.Comic.t} |
  {:error, String.t}

Takes a number from 1 to the latest and returns a tuple with with :ok and a comic struct or an :error atom and an error message

Example:

iex> Xkcd.number(256)
{:ok, %Xkcd.Comic{...}}

iex> Xkcd.number(0)
{:error, "Comic Not Found"}
random()

Specs

random :: {:ok, Xkcd.Comic.t}

Gets a random comic and returns a tuple with :ok and a comic struct

Example:

iex> Xkcd.random
{:ok, %Xkcd.Comic{...}}