class PiSys::Vcgencmd

Constants

COMMANDS

Public Class Methods

new(key, command) click to toggle source
Calls superclass method PiSys::Stats::new
# File lib/pi-sys/stats/vcgencmd.rb, line 13
def initialize(key, command)
  @key, @command = key, command
  super(@key, nil)
end

Public Instance Methods

fetch(command=@command) click to toggle source
# File lib/pi-sys/stats/vcgencmd.rb, line 18
def fetch(command=@command)
  if COMMANDS.has_key? command
    if COMMANDS[command]
      hash ||= {}
      COMMANDS[command].each do |option|
        output = run_command(command, option)
        if output
          hash[option] = Hash[output.strip.split("\n").map {|entry| entry.split('=')}]
        end
      end
      hash
    else
      output = run_command(command)
      if output
        Hash[output.strip.split("\n").map {|entry| entry.split('=')}]
      else
        {}
      end
    end
  end
end
run_command(command, option=nil) click to toggle source
Calls superclass method PiSys::Stats#run_command
# File lib/pi-sys/stats/vcgencmd.rb, line 40
def run_command(command, option=nil)
  super("/opt/vc/bin/vcgencmd #{command} #{option.to_s}")
end