Class: CacheBuster::Pi
- Inherits:
-
Object
- Object
- CacheBuster::Pi
- Defined in:
- lib/cache-buster/pi.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Pi
constructor
A new instance of Pi.
- #watch_buttons ⇒ Object
Constructor Details
#initialize ⇒ Pi
Returns a new instance of Pi.
4 5 6 |
# File 'lib/cache-buster/pi.rb', line 4 def initialize end |
Class Method Details
.hard ⇒ Object
20 21 22 |
# File 'lib/cache-buster/pi.rb', line 20 def self.hard run Proc.new { Rackspace.new.clear } end |
.run(proc) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cache-buster/pi.rb', line 28 def self.run(proc) red = PiPiper::Pin.new(pin: ENV['RED_PIN'].to_i, direction: :out) green = PiPiper::Pin.new(pin: ENV['GREEN_PIN'].to_i, direction: :out) red.on proc.call red.off green.on sleep 5 green.off red.release green.release exit if ENV['TEST'] end |
.soft ⇒ Object
24 25 26 |
# File 'lib/cache-buster/pi.rb', line 24 def self.soft run Proc.new { Cloudflare.new.clear } end |
Instance Method Details
#watch_buttons ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cache-buster/pi.rb', line 8 def PiPiper.watch pin: ENV['SOFT_BUTTON'].to_i do CacheBuster::Pi.soft end PiPiper.watch pin: ENV['HARD_BUTTON'].to_i do CacheBuster::Pi.hard end PiPiper.wait end |