Class: NRB::BreweryControlSystem::API::TemperatureProbesEndpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api: nil) ⇒ TemperatureProbesEndpoint

Returns a new instance of TemperatureProbesEndpoint.

Raises:

  • (ArgumentError)


32
33
34
35
# 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

Class Method Details

.fetch(api: nil) ⇒ Object



6
7
8
# File 'lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb', line 6

def fetch(api: nil)
  new(api: api).fetch
end

Instance Method Details

#fetchObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# 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) ⇒ Object



27
28
29
# File 'lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb', line 27

def http_service &block
  api.http_service &block
end