Class: Fuzzyurl::Protocols

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzyurl/protocols.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.get_port(protocol) ⇒ Object



15
16
17
18
19
# File 'lib/fuzzyurl/protocols.rb', line 15

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

.get_protocol(port) ⇒ Object



21
22
23
# File 'lib/fuzzyurl/protocols.rb', line 21

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