Module: Matchd::Glue::AsyncEndpoint
- Defined in:
- lib/matchd/glue/async_endpoint.rb
Overview
Wrapper for allowing a more flexible way of defining interfaces for Asyc-*
Constant Summary collapse
- PROTOCOLS =
Supported DNS protocols
%w(udp tcp).freeze
- DEFAULT_PORT =
Default port used when the port is omitted in Hash or String notation.
53
Class Method Summary collapse
-
.parse(args) ⇒ Object
Examples:.
Class Method Details
.parse(args) ⇒ Object
Examples:
# classic triplet array
AsyncIntrface.parse([:udp, "0.0.0.0", 53])
AsyncIntrface.parse([[:udp, "0.0.0.0", 53], [:tcp, "0.0.0.0", 53]])
# Hash notation
AsyncIntrface.parse({"protocol" => :udp, "ip" => "0.0.0.0", "port" => 53})
AsyncIntrface.parse({protocol: :udp, ip: "0.0.0.0", port: 53})
AsyncIntrface.parse([{protocol: :udp, ip: "0.0.0.0", port: 53}, {protocol: :tcp, ip: "0.0.0.0", port: 53}])
# URI strings
AsyncIntrface.parse("udp://0.0.0.0:53")
AsyncIntrface.parse(["udp://0.0.0.0:53", "tcp://0.0.0.0:53"])
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/matchd/glue/async_endpoint.rb', line 19 def parse(args) val = case args when Array if triplet = parse_array(args) [triplet] else args.flat_map { |e| parse(e) } end when Hash [parse_hash(args)] when String [parse_uri(args)] end return nil unless val val.compact! val.empty? ? nil : val end |