Last active
August 29, 2015 13:59
-
-
Save l0gicpath/10850742 to your computer and use it in GitHub Desktop.
Consuming arabic tech content workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fun exercise with Elixir. | |
# The joke's on arabic tech news and yes it's that bad I had to write this. | |
# That's an elixir script hence .exs so run it with | |
# > elixir kill_braincells.exs | |
defmodule Content do | |
@moduledoc """ | |
Content is responsible for consuming different types of content | |
""" | |
@doc """ | |
consume content in different types and return whether this content will kill something | |
or enrich something | |
""" | |
def consume([{:news, "arabic"} | _]) do | |
:kill | |
end | |
def consume([{:news, _} | _]) do | |
:enrich | |
end | |
def consume(_) do | |
"It's not even funny anymore, stop poking around!" | |
end | |
end | |
defmodule Human do | |
@moduledoc """ | |
Human is a representation of you, you are a human aren't you? Okay good. | |
""" | |
@doc """ | |
brain represents your human brain with different parts that can be affected as | |
a result of consuming certain types of content | |
""" | |
def brain(action, :cells) do | |
case action do | |
:kill -> :poorly | |
:enrich -> :better | |
_ -> "Man, for real... Stop poking around." | |
end | |
end | |
def brain(_, _) do | |
"Sorry, your brain doesn't have that." | |
end | |
end | |
defmodule Work do | |
@moduledoc """ | |
Work represents your work, duh. | |
""" | |
@doc """ | |
Perform allows you to perform work with a certain level of quality depending on | |
what part of your human body did you kill consuming specific types of content | |
""" | |
def perform(:poorly) do | |
"welp, you're shit outta luck." | |
end | |
def perform(:better) do | |
"Yo been reading quality shizzles haven't ya, eh? ;-)" | |
end | |
def perform(_) do | |
"Quit your job, for real. Get a nice couch, LCD TV and some chips with a T-Shirt that says, life's good." | |
end | |
end | |
IO.puts Content.consume([news: "arabic"]) |> | |
Human.brain(:cells) |> | |
Work.perform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment