Class: IStats::Cpu

Inherits:
Object
  • Object
show all
Extended by:
CPU_STATS
Defined in:
lib/iStats/cpu.rb

Class Method Summary collapse

Methods included from CPU_STATS

get_cpu_temp

Class Method Details

.allObject

Call all functions (stats)



24
25
26
# File 'lib/iStats/cpu.rb', line 24

def all
  cpu_temperature
end

.cpu_temperatureObject

Print CPU temperature with sparkline



30
31
32
33
34
# File 'lib/iStats/cpu.rb', line 30

def cpu_temperature
  t = get_cpu_temp
  thresholds = [50, 68, 80, 90]
  puts "CPU temp: #{t}#{Symbols.degree}C  " + Printer.gen_sparkline(t, thresholds)
end

.delegate(stat) ⇒ Object

Delegate CLI command to function



11
12
13
14
15
16
17
18
19
20
# File 'lib/iStats/cpu.rb', line 11

def delegate(stat)
  case stat
  when 'all'
    all
  when 'temp', 'temperature'
    cpu_temperature
  else
    Command.help "Unknown stat for CPU: #{stat}"
  end
end