Add cowthunk function, counterpart to cowsaid

This commit is contained in:
Thomas A. Christensen II 2022-02-01 16:03:30 -06:00
parent d8a67143b3
commit ee130aa35a
Signed by: millironx
GPG key ID: 139C07724802BC5D

View file

@ -3,6 +3,7 @@ module Cowsay
export cowsay export cowsay
export cowthink export cowthink
export cowsaid export cowsaid
export cowthunk
include("cows/blowfish.cow.jl") include("cows/blowfish.cow.jl")
include("cows/bunny.cow.jl") include("cows/bunny.cow.jl")
@ -89,8 +90,7 @@ Print an ASCII picture of a cow thinking `message`
See [`cowsay`](@ref) See [`cowsay`](@ref)
""" """
function cowthink(message::AbstractString; cow=default, eyes="oo", tongue=" ") function cowthink(message::AbstractString; cow=default, eyes="oo", tongue=" ")
balloon = thinkballoon(message) println(cowthunk(message, cow=cow, eyes=eyes, tongue=tongue))
println(string(balloon, cow(eyes=eyes, tongue=tongue, thoughts="o")))
end end
""" """
@ -106,12 +106,22 @@ for implementation details.
julia> cowsaid("Have you mooed today?") julia> cowsaid("Have you mooed today?")
" _______________________\\n< Have you mooed today? >\\n -----------------------\\n \\\\ ^__^\\n \\\\ (oo)\\\\_______\\n (__)\\\\ )\\\\/\\\\\\n ||----w |\\n || ||\\n" " _______________________\\n< Have you mooed today? >\\n -----------------------\\n \\\\ ^__^\\n \\\\ (oo)\\\\_______\\n (__)\\\\ )\\\\/\\\\\\n ||----w |\\n || ||\\n"
``` ```
```jldoctest
julia> cowthunk("Have I mooed today?")
" _____________________\\n( Have I mooed today? )\\n ---------------------\\n o ^__^\\n o (oo)\\\\_______\\n (__)\\\\ )\\\\/\\\\\\n ||----w |\\n || ||\\n"
```
""" """
function cowsaid(message::AbstractString; cow=default, eyes="oo", tongue=" ") function cowsaid(message::AbstractString; cow=default, eyes="oo", tongue=" ")
balloon = sayballoon(message) balloon = sayballoon(message)
return string(balloon, cow(eyes=eyes, tongue=tongue)) return string(balloon, cow(eyes=eyes, tongue=tongue))
end end
function cowthunk(message::AbstractString; cow=default, eyes="oo", tongue=" ")
balloon = thinkballoon(message)
return string(balloon, cow(eyes=eyes, tongue=tongue, thoughts="o"))
end
""" """
function sayballoon(message::AbstractString) function sayballoon(message::AbstractString)