Last active
December 29, 2020 15:26
-
-
Save gallexme/1f3817bf1e9aaf56f1592735f911e953 to your computer and use it in GitHub Desktop.
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
@doc "Alle drehenede x" | |
defprotocol Drehzahl do | |
@doc "Berechnet die Aktuelle Drehzahl" | |
def rpm(device) | |
end | |
defimpl Drehzahl, for: Any do | |
def rpm(any), do: any.rpm | |
end | |
defmodule Pumpe do | |
@derive [Drehzahl]s | |
defstruct [:name, :rpm, :volumeperhour] | |
end | |
defmodule Motor do | |
@derive [Drehzahl] | |
defstruct [:name, :torgue, :rpm] | |
end | |
defmodule WindRad do | |
defstruct [:name, :location, :wind, :weight] | |
end | |
defimpl Drehzahl, for: WindRad do | |
def rpm(windrad), do: windrad.wind * windrad.weight | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment