Class: Galaxy::Slot

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

Overview

Slot Information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid, short_id, url, binary, config, status, status_message, path) ⇒ Slot

Returns a new instance of Slot.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/galaxy.rb', line 41

def initialize(uuid, short_id, url, binary, config, status, status_message, path)
  @uuid = uuid
  @short_id = short_id
  @url = url
  @binary = binary
  @config = config
  @status = status
  @status_message = status_message
  @path = path

  unless url.nil?
    @host = URI.parse(url).host unless url.nil?
    @ip = IPSocket::getaddress(host)
  end

  @host ||= "unknown"
  @ip ||= "unknown"
end

Instance Attribute Details

#binaryObject (readonly)

Returns the value of attribute binary.



39
40
41
# File 'lib/galaxy.rb', line 39

def binary
  @binary
end

#configObject (readonly)

Returns the value of attribute config.



39
40
41
# File 'lib/galaxy.rb', line 39

def config
  @config
end

#hostObject (readonly)

Returns the value of attribute host.



39
40
41
# File 'lib/galaxy.rb', line 39

def host
  @host
end

#ipObject (readonly)

Returns the value of attribute ip.



39
40
41
# File 'lib/galaxy.rb', line 39

def ip
  @ip
end

#pathObject (readonly)

Returns the value of attribute path.



39
40
41
# File 'lib/galaxy.rb', line 39

def path
  @path
end

#short_idObject (readonly)

Returns the value of attribute short_id.



39
40
41
# File 'lib/galaxy.rb', line 39

def short_id
  @short_id
end

#statusObject (readonly)

Returns the value of attribute status.



39
40
41
# File 'lib/galaxy.rb', line 39

def status
  @status
end

#status_messageObject (readonly)

Returns the value of attribute status_message.



39
40
41
# File 'lib/galaxy.rb', line 39

def status_message
  @status_message
end

#urlObject (readonly)

Returns the value of attribute url.



39
40
41
# File 'lib/galaxy.rb', line 39

def url
  @url
end

#uuidObject (readonly)

Returns the value of attribute uuid.



39
40
41
# File 'lib/galaxy.rb', line 39

def uuid
  @uuid
end

Instance Method Details

#columns(colors = false) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/galaxy.rb', line 60

def columns(colors = false)
  status = @status
  status_message = @status_message

  if colors
    status = case status
      when "RUNNING" then Colorize::colorize(status, :bright, :green)
      when "STOPPED" then status
      else status
    end
    status_message = Colorize::colorize(status_message, :red)
  end

  return [@short_id, @host, status, @binary, @config, status_message].map { |value| value || '' }
end