bob
This commit is contained in:
23
elixir/bob/lib/bob.ex
Normal file
23
elixir/bob/lib/bob.ex
Normal file
@@ -0,0 +1,23 @@
|
||||
defmodule Bob do
|
||||
@spec hey(String.t()) :: String.t()
|
||||
def hey(input) do
|
||||
trimmed = String.trim(input)
|
||||
|
||||
is_yell? = String.upcase(trimmed) == trimmed and String.downcase(trimmed) != trimmed
|
||||
is_question? = String.ends_with?(trimmed, "?")
|
||||
is_silence? = trimmed == ""
|
||||
|
||||
cond do
|
||||
is_silence? ->
|
||||
"Fine. Be that way!"
|
||||
is_yell? and is_question? ->
|
||||
"Calm down, I know what I'm doing!"
|
||||
is_question? ->
|
||||
"Sure."
|
||||
is_yell? ->
|
||||
"Whoa, chill out!"
|
||||
true ->
|
||||
"Whatever."
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user