Ruby 2.5.0 リファレンスマニュアル > ライブラリ一覧 > uriライブラリ > URI::Genericクラス > default_port

singleton method URI::Generic.default_port

default_port -> Integer | nil[permalink][rdoc]

スキームに対応するデフォルトのポート番号を整数で返します。

require 'uri'
URI::Generic.default_port     # => nil
URI::FTP.default_port         # => 21
URI::HTTP.default_port        # => 80
URI::HTTPS.default_port       # => 443
URI::LDAP.default_port        # => 389
URI::LDAPS.default_port       # => 636
URI::MailTo.default_port      # => nil