Class: MistApi::CpuStat
- Defined in:
- lib/mist_api/models/cpu_stat.rb
Overview
CpuStat Model.
Instance Attribute Summary collapse
-
#idle ⇒ Float
Percentage of CPU time that is idle.
-
#interrupt ⇒ Float
Percentage of CPU time being used by interrupts.
-
#load_avg ⇒ Array[Float]
Load averages for the last 1, 5, and 15 minutes.
-
#system ⇒ Float
Percentage of CPU time being used by system processes.
-
#usage ⇒ Float
CPU usage.
-
#user ⇒ Float
Percentage of CPU time being used by user processes.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(idle = SKIP, interrupt = SKIP, load_avg = SKIP, system = SKIP, usage = SKIP, user = SKIP) ⇒ CpuStat
constructor
A new instance of CpuStat.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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
#idle ⇒ Float
Percentage of CPU time that is idle
14 15 16 |
# File 'lib/mist_api/models/cpu_stat.rb', line 14 def idle @idle end |
#interrupt ⇒ Float
Percentage of CPU time being used by interrupts
18 19 20 |
# File 'lib/mist_api/models/cpu_stat.rb', line 18 def interrupt @interrupt end |
#load_avg ⇒ Array[Float]
Load averages for the last 1, 5, and 15 minutes
22 23 24 |
# File 'lib/mist_api/models/cpu_stat.rb', line 22 def load_avg @load_avg end |
#system ⇒ Float
Percentage of CPU time being used by system processes
26 27 28 |
# File 'lib/mist_api/models/cpu_stat.rb', line 26 def system @system end |
#usage ⇒ Float
CPU usage
30 31 32 |
# File 'lib/mist_api/models/cpu_stat.rb', line 30 def usage @usage end |
#user ⇒ Float
Percentage of CPU time being used by user processes
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
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 |
.optionals ⇒ Object
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
#inspect ⇒ Object
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_s ⇒ Object
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 |