File: protocols.rb

package info (click to toggle)
ruby-fuzzyurl 0.8.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 168 kB
  • sloc: ruby: 517; makefile: 3
file content (26 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Fuzzyurl::Protocols
  PORTS_BY_PROTOCOL = {
    'ssh' => '22',
    'http' => '80',
    'https' => '443'
  }

  PROTOCOLS_BY_PORT = {
    '22' => 'ssh',
    '80' => 'http',
    '443' => 'https'
  }

  class << self
    def get_port(protocol)
      return nil unless protocol
      base_protocol = protocol.split('+').last
      PORTS_BY_PROTOCOL[base_protocol.to_s]
    end

    def get_protocol(port)
      PROTOCOLS_BY_PORT[port.to_s]
    end
  end
end