Class: Knj::Power_manager
Instance Method Summary collapse
- 
  
    
      #initialize(args = {})  ⇒ Power_manager 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Power_manager.
 - #state ⇒ Object
 
Constructor Details
#initialize(args = {}) ⇒ Power_manager
Returns a new instance of Power_manager.
      2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  | 
    
      # File 'lib/knj/power_manager.rb', line 2 def initialize(args = {}) @args = args if !File.exist?("/proc/acpi/ac_adapter") raise "Could not find the proc-acpi folder." end Dir.new("/proc/acpi/ac_adapter").each do |file| next if file == "." or file == ".." fn = "/proc/acpi/ac_adapter/#{file}" if File.directory?(fn) @ac_folder = Php4r.realpath(fn) break end end raise "Could not register ac-folder." if !@ac_folder end  | 
  
Instance Method Details
#state ⇒ Object
      22 23 24 25 26 27 28 29 30  | 
    
      # File 'lib/knj/power_manager.rb', line 22 def state cont = File.read("#{@ac_folder}/state") if match = cont.match(/state:\s*(.+)\s*/) return match[1] end raise "Could not figure out state." end  |