Class: Gitlab::Ci::Build::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/build/port.rb

Constant Summary collapse

DEFAULT_PORT_NAME =
'default_port'
DEFAULT_PORT_PROTOCOL =
'http'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ Port

Returns a new instance of Port.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/ci/build/port.rb', line 12

def initialize(port)
  @name = DEFAULT_PORT_NAME
  @protocol = DEFAULT_PORT_PROTOCOL

  case port
  when Integer
    @number = port
  when Hash
    @number = port[:number]
    @protocol = port.fetch(:protocol, @protocol)
    @name = port.fetch(:name, @name)
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/gitlab/ci/build/port.rb', line 10

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



10
11
12
# File 'lib/gitlab/ci/build/port.rb', line 10

def number
  @number
end

#protocolObject (readonly)

Returns the value of attribute protocol.



10
11
12
# File 'lib/gitlab/ci/build/port.rb', line 10

def protocol
  @protocol
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/gitlab/ci/build/port.rb', line 26

def valid?
  @number.present?
end