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
35
36
37
38
# File 'lib/iStats/cpu.rb', line 30

def cpu_temperature
  t = get_cpu_temp
  thresholds = [50, 68, 80, 90]
  value, scale = Printer.parse_temperature(t)
  if Printer.get_temperature_scale == 'fahrenheit'
    thresholds.map! { |t| Utils.to_fahrenheit(t) }
  end
  Printer.print_item_line("CPU temp", value, scale, 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