Current section

Files

Jump to
crawlberg lib crawlberg image_info.ex
Raw

lib/crawlberg/image_info.ex

# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:033f5eca7fbc34bfd4671a4317e70b36ebfd9f5f5cf417b942c113c920a71e34
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
defmodule Crawlberg.ImageInfo do
@moduledoc "Information about an image found on a page."
@typedoc "Information about an image found on a page."
@type t :: %__MODULE__{
url: String.t() | nil,
alt: String.t() | nil,
width: non_neg_integer() | nil,
height: non_neg_integer() | nil,
source: String.t() | nil
}
defstruct url: nil,
alt: nil,
width: nil,
height: nil,
source: :img
defimpl Jason.Encoder do
@doc false
def encode(value, opts) do
value
|> Map.from_struct()
|> Enum.reject(fn {_k, v} -> v == nil end)
|> Enum.into(%{})
|> Jason.Encoder.encode(opts)
end
end
end