Class: MistApi::CpuStat

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/cpu_stat.rb

Overview

CpuStat Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(idle = SKIP, interrupt = SKIP, load_avg = SKIP, system = SKIP, usage = SKIP, user = SKIP) ⇒ CpuStat

Returns a new instance of CpuStat.



71
72
73
74
75
76
77
78
79
# File 'lib/mist_api/models/cpu_stat.rb', line 71

def initialize(idle = SKIP, interrupt = SKIP, load_avg = SKIP,
               system = SKIP, usage = SKIP, user = SKIP)
  @idle = idle unless idle == SKIP
  @interrupt = interrupt unless interrupt == SKIP
  @load_avg = load_avg unless load_avg == SKIP
  @system = system unless system == SKIP
  @usage = usage unless usage == SKIP
  @user = user unless user == SKIP
end

Instance Attribute Details

#idleFloat

Percentage of CPU time that is idle

Returns:

  • (Float)


14
15
16
# File 'lib/mist_api/models/cpu_stat.rb', line 14

def idle
  @idle
end

#interruptFloat

Percentage of CPU time being used by interrupts

Returns:

  • (Float)


18
19
20
# File 'lib/mist_api/models/cpu_stat.rb', line 18

def interrupt
  @interrupt
end

#load_avgArray[Float]

Load averages for the last 1, 5, and 15 minutes

Returns:

  • (Array[Float])


22
23
24
# File 'lib/mist_api/models/cpu_stat.rb', line 22

def load_avg
  @load_avg
end

#systemFloat

Percentage of CPU time being used by system processes

Returns:

  • (Float)


26
27
28
# File 'lib/mist_api/models/cpu_stat.rb', line 26

def system
  @system
end

#usageFloat

CPU usage

Returns:

  • (Float)


30
31
32
# File 'lib/mist_api/models/cpu_stat.rb', line 30

def usage
  @usage
end

#userFloat

Percentage of CPU time being used by user processes

Returns:

  • (Float)


34
35
36
# File 'lib/mist_api/models/cpu_stat.rb', line 34

def user
  @user
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/mist_api/models/cpu_stat.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  idle = hash.key?('idle') ? hash['idle'] : SKIP
  interrupt = hash.key?('interrupt') ? hash['interrupt'] : SKIP
  load_avg = hash.key?('load_avg') ? hash['load_avg'] : SKIP
  system = hash.key?('system') ? hash['system'] : SKIP
  usage = hash.key?('usage') ? hash['usage'] : SKIP
  user = hash.key?('user') ? hash['user'] : SKIP

  # Create object from extracted values.
  CpuStat.new(idle,
              interrupt,
              load_avg,
              system,
              usage,
              user)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/mist_api/models/cpu_stat.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['idle'] = 'idle'
  @_hash['interrupt'] = 'interrupt'
  @_hash['load_avg'] = 'load_avg'
  @_hash['system'] = 'system'
  @_hash['usage'] = 'usage'
  @_hash['user'] = 'user'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
64
65
66
67
68
69
# File 'lib/mist_api/models/cpu_stat.rb', line 61

def self.nullables
  %w[
    idle
    interrupt
    system
    usage
    user
  ]
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/mist_api/models/cpu_stat.rb', line 49

def self.optionals
  %w[
    idle
    interrupt
    load_avg
    system
    usage
    user
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/mist_api/models/cpu_stat.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} idle: #{@idle.inspect}, interrupt: #{@interrupt.inspect}, load_avg:"\
  " #{@load_avg.inspect}, system: #{@system.inspect}, usage: #{@usage.inspect}, user:"\
  " #{@user.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



103
104
105
106
107
# File 'lib/mist_api/models/cpu_stat.rb', line 103

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} idle: #{@idle}, interrupt: #{@interrupt}, load_avg: #{@load_avg}, system:"\
  " #{@system}, usage: #{@usage}, user: #{@user}>"
end