Skip to content

Commit d256b14

Browse files
authored
Update documentation for seems?/2 explaining what nil means (#8)
* Update documentation for `seems?/2` explaining what `nil` means * Add image_format type and update typespec
1 parent d741c5c commit d256b14

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/ex_image_info.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,17 @@ defmodule ExImageInfo do
7676
# but still keeping :png as the first
7777
@types [:png, :jpeg, :gif, :bmp, :ico, :tiff, :webp, :psd, :jp2, :pnm]
7878

79+
@type image_format :: :png | :jpeg | :gif | :bmp | :ico | :tiff | :webp | :psd | :jp2 | :pnm
80+
7981
## Public API
8082

8183
@doc """
8284
Detects if the given binary seems to be in the given image format.
8385
8486
Valid [formats](#module-formats) to be used.
8587
86-
Returns `true` if seems to be, `false` otherwise.
88+
Returns `true` if the binary seems to be the format specified, `false` if it
89+
is not, and `nil` if the type is unsupported.
8790
8891
## Examples
8992
@@ -143,7 +146,7 @@ defmodule ExImageInfo do
143146
webp_full_binary |> ExImageInfo.seems?
144147
# :webp
145148
"""
146-
@spec seems?(binary) :: atom | nil
149+
@spec seems?(binary) :: image_format() | nil
147150
def seems?(binary), do: try_seems?(binary, @types)
148151

149152
@doc """

lib/ex_image_info/detector.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ defmodule ExImageInfo.Detector do
33

44
@callback info(binary) :: {mimetype :: String.t, width :: Integer.t, height :: Integer.t, variant :: String.t} | nil
55
@callback type(binary) :: {mimetype :: String.t, variant :: String.t} | nil
6-
@callback seems?(binary) :: Boolean.t
6+
@callback seems?(binary) :: boolean()
77
end

0 commit comments

Comments
 (0)