class API
Attributes
status[RW]
Public Instance Methods
failed()
click to toggle source
# File lib/api.rb, line 14 def failed light(:red) end
finished()
click to toggle source
# File lib/api.rb, line 18 def finished return unless yellow? light(:green) end
started()
click to toggle source
# File lib/api.rb, line 10 def started light(:yellow) end
Private Instance Methods
light(color)
click to toggle source
# File lib/api.rb, line 25 def light(color) uri = uri(color) Net::HTTP.new(uri.host, uri.port).get(uri.path, {}) @status = color end
uri(color)
click to toggle source
# File lib/api.rb, line 31 def uri(color) base_uri = ENV['ARDUINO_IP'] || "http://localhost:3000" URI("#{base_uri}/#{color}") end
yellow?()
click to toggle source
# File lib/api.rb, line 36 def yellow? @status == :yellow end