Class: CfScript::AppInfo
- Inherits:
-
Object
- Object
- CfScript::AppInfo
- Defined in:
- lib/cf_script/object/app_info.rb
Instance Attribute Summary collapse
-
#buildpack ⇒ Object
readonly
Returns the value of attribute buildpack.
-
#disk ⇒ Object
readonly
Returns the value of attribute disk.
-
#instance_status ⇒ Object
readonly
This gets set after some commands, like push and start.
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
-
#last_uploaded ⇒ Object
readonly
Returns the value of attribute last_uploaded.
-
#memory ⇒ Object
readonly
These are available from ‘cf apps` only.
-
#name ⇒ Object
readonly
These are always available.
-
#requested_state ⇒ Object
readonly
Returns the value of attribute requested_state.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
-
#usage ⇒ Object
readonly
These are available from ‘cf app` only.
Instance Method Summary collapse
-
#initialize(name, attrs) ⇒ AppInfo
constructor
A new instance of AppInfo.
- #set_instance_status(instance_statuses) ⇒ Object
- #started? ⇒ Boolean (also: #hot?)
- #state ⇒ Object
- #stopped? ⇒ Boolean (also: #cold?)
- #update(attrs) ⇒ Object
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
#buildpack ⇒ Object (readonly)
Returns the value of attribute buildpack.
12 13 14 |
# File 'lib/cf_script/object/app_info.rb', line 12 def buildpack @buildpack end |
#disk ⇒ Object (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_status ⇒ Object (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 |
#instances ⇒ Object (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_uploaded ⇒ Object (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 |
#memory ⇒ Object (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 |
#name ⇒ Object (readonly)
These are always available
3 4 5 |
# File 'lib/cf_script/object/app_info.rb', line 3 def name @name end |
#requested_state ⇒ Object (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 |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
11 12 13 |
# File 'lib/cf_script/object/app_info.rb', line 11 def stack @stack end |
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
6 7 8 |
# File 'lib/cf_script/object/app_info.rb', line 6 def urls @urls end |
#usage ⇒ Object (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?
31 32 33 |
# File 'lib/cf_script/object/app_info.rb', line 31 def started? state == 'started' end |
#state ⇒ Object
27 28 29 |
# File 'lib/cf_script/object/app_info.rb', line 27 def state requested_state end |
#stopped? ⇒ Boolean Also known as: cold?
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 |