Skip to content

Instantly share code, notes, and snippets.

@gallexme
Last active December 29, 2020 15:26
Show Gist options
  • Save gallexme/1f3817bf1e9aaf56f1592735f911e953 to your computer and use it in GitHub Desktop.
Save gallexme/1f3817bf1e9aaf56f1592735f911e953 to your computer and use it in GitHub Desktop.
@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