Skip to content

qertoip/battery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

battery

API to your laptop's battery.

Based on the UPower tool available by default on Ubuntu and Debian distros. Other data sources can be easilly added as plugins.

Example

battery = Battery.new
battery.energy_left          # =>   0.97  (almost fully charged)
battery.voltage              # =>  12.78  [V]
battery.charging?            # =>  true
battery.vendor               # =>  'Panasonic'
battery.update.energy_left   # =>   0.96  (notice the updated value)

See the acceptance tests for the exhaustive list of examples. Don't fear to look at the code.

Installation

Add this to your Gemfile:

gem 'battery'

Then run:

bundle

Requirements

  • Ruby 1.9.2

Running tests

Run all tests:

bundle exec rake test

Run only functional tests:

bundle exec rake test:functional

Run only acceptance tests:

bundle exec rake test:acceptance

License

Released under the MIT license. Copyright (C) 2012 Piotr 'Qertoip' Włodarek.

About

Ruby API to your laptop's battery.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages