class K8sInternalLb::Port
Attributes
name[RW]
port[R]
protocol[R]
Public Class Methods
new(name: nil, port:, protocol: :TCP)
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 8 def initialize(name: nil, port:, protocol: :TCP) name = nil if name&.empty? @name = name self.port = port self.protocol = protocol end
Public Instance Methods
==(other)
click to toggle source
Equality overriding
# File lib/k8s_internal_lb/port.rb, line 53 def ==(other) return unless other.respond_to?(:name) && other.respond_to?(:port) && other.respond_to?(:protocol) name == other.name && port == other.port && protocol == other.protocol end
eql?(other)
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 63 def eql?(other) self == other end
hash()
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 59 def hash [name, port, protocol].hash end
port=(port)
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 23 def port=(port) port = port.to_i unless port.is_a? Integer raise ArgumentError, 'Port must be a valid port number' unless (1..65_535).include? port @port = port end
protocol=(protocol)
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 15 def protocol=(protocol) protocol = protocol.to_s.upcase.to_sym raise ArgumentError, 'Protocol must be one of :TCP, :UDP, :SCTP' unless %i[TCP UDP SCTP].include? protocol @protocol = protocol end
sctp?()
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 39 def sctp? protocol == :SCTP end
tcp?()
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 31 def tcp? protocol == :TCP end
to_json(*params)
click to toggle source
JSON encoding
# File lib/k8s_internal_lb/port.rb, line 44 def to_json(*params) { name: name, port: port, protocol: protocol }.compact.to_json(*params) end
udp?()
click to toggle source
# File lib/k8s_internal_lb/port.rb, line 35 def udp? protocol == :UDP end