Created
September 25, 2015 13:28
-
-
Save brweber2/a0b89a7c7dbdfaf0763c to your computer and use it in GitHub Desktop.
Custom Sigil with pattern matching...
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
def magic(nbr) do | |
a = ~x(a1b2c3d4) | |
b = ~x(d4c3b2a1) | |
c = ~x(a1b23c4d) | |
d = ~x(4d3cb2a1) | |
case nbr do | |
^a -> %Pcap.Global.MagicNumber{ magic_number: nbr, swap_fields: false, nanoseconds: false } | |
^b -> %Pcap.Global.MagicNumber{ magic_number: nbr, swap_fields: true, nanoseconds: false } | |
^c -> %Pcap.Global.MagicNumber{ magic_number: nbr, swap_fields: false, nanoseconds: true } | |
^d -> %Pcap.Global.MagicNumber{ magic_number: nbr, swap_fields: true, nanoseconds: true } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment