Class: CfScript::AppInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_script/object/app_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attrs) ⇒ AppInfo

Returns a new instance of AppInfo.



21
22
23
24
25
# File 'lib/cf_script/object/app_info.rb', line 21

def initialize(name, attrs)
  @name = name

  update(attrs)
end

Instance Attribute Details

#buildpackObject (readonly)

Returns the value of attribute buildpack.



12
13
14
# File 'lib/cf_script/object/app_info.rb', line 12

def buildpack
  @buildpack
end

#diskObject (readonly)

Returns the value of attribute disk.



16
17
18
# File 'lib/cf_script/object/app_info.rb', line 16

def disk
  @disk
end

#instance_statusObject (readonly)

This gets set after some commands, like push and start



19
20
21
# File 'lib/cf_script/object/app_info.rb', line 19

def instance_status
  @instance_status
end

#instancesObject (readonly)

Returns the value of attribute instances.



5
6
7
# File 'lib/cf_script/object/app_info.rb', line 5

def instances
  @instances
end

#last_uploadedObject (readonly)

Returns the value of attribute last_uploaded.



10
11
12
# File 'lib/cf_script/object/app_info.rb', line 10

def last_uploaded
  @last_uploaded
end

#memoryObject (readonly)

These are available from ‘cf apps` only



15
16
17
# File 'lib/cf_script/object/app_info.rb', line 15

def memory
  @memory
end

#nameObject (readonly)

These are always available



3
4
5
# File 'lib/cf_script/object/app_info.rb', line 3

def name
  @name
end

#requested_stateObject (readonly)

Returns the value of attribute requested_state.



4
5
6
# File 'lib/cf_script/object/app_info.rb', line 4

def requested_state
  @requested_state
end

#stackObject (readonly)

Returns the value of attribute stack.



11
12
13
# File 'lib/cf_script/object/app_info.rb', line 11

def stack
  @stack
end

#urlsObject (readonly)

Returns the value of attribute urls.



6
7
8
# File 'lib/cf_script/object/app_info.rb', line 6

def urls
  @urls
end

#usageObject (readonly)

These are available from ‘cf app` only



9
10
11
# File 'lib/cf_script/object/app_info.rb', line 9

def usage
  @usage
end

Instance Method Details

#set_instance_status(instance_statuses) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/cf_script/object/app_info.rb', line 62

def set_instance_status(instance_statuses)
  @instance_status = []

  instance_statuses.each do |instance_status|
    @instance_status << CfScript::InstanceStatus.new(instance_status)
  end
end

#started?Boolean Also known as: hot?

Returns:

  • (Boolean)


31
32
33
# File 'lib/cf_script/object/app_info.rb', line 31

def started?
  state == 'started'
end

#stateObject



27
28
29
# File 'lib/cf_script/object/app_info.rb', line 27

def state
  requested_state
end

#stopped?Boolean Also known as: cold?

Returns:

  • (Boolean)


37
38
39
# File 'lib/cf_script/object/app_info.rb', line 37

def stopped?
  state == 'stopped'
end

#update(attrs) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cf_script/object/app_info.rb', line 43

def update(attrs)
  @requested_state = attrs.key?(:requested_state) ? attrs[:requested_state].value : nil
  @instances       = attrs.key?(:instances) ? attrs[:instances].value : nil

  @urls            = attrs.key?(:urls) ? attrs[:urls].to_a : []

  @usage           = attrs.key?(:usage) ? attrs[:usage].value : nil
  @last_uploaded   = attrs.key?(:last_uploaded) ? attrs[:last_uploaded].value : nil
  @stack           = attrs.key?(:stack) ? attrs[:stack].value : nil
  @buildpack       = attrs.key?(:buildpack) ? attrs[:buildpack].value : nil

  @memory          = attrs.key?(:memory) ? attrs[:memory].value : nil
  @disk            = attrs.key?(:disk) ? attrs[:disk].value :  nil

  if @memory.nil? and @usage
    @memory = @usage.split(' ').first
  end
end