class NRB::BreweryControlSystem::API::TemperatureProbesEndpoint

Attributes

api[RW]

Public Class Methods

fetch(api: nil) click to toggle source
# File lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb, line 6
def fetch(api: nil)
  new(api: api).fetch
end
new(api: nil) click to toggle source
# File lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb, line 32
def initialize(api: nil)
  raise ArgumentError.new("Need an api") if api.nil?
  self.api = api
end

Public Instance Methods

fetch() click to toggle source
# File lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb, line 12
def fetch
  names = http_service do |b|
            b.response TemperatureProbeNamesEndpoint
          end.get(TemperatureProbeNamesEndpoint.endpoint).body
  ultemp = http_service do |b|
                b.response Ultemp
              end.get(Ultemp.endpoint).body
  temps = ultemp[34..41]
  setpoints = ultemp[42..49]
  names.each_with_index.collect do |name,i|
    NRB::BreweryControlSystem::TemperatureProbe.new name, temps[i], setpoints[i]
  end
end
http_service(&block) click to toggle source
# File lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb, line 27
def http_service &block
  api.http_service &block
end